For a given Django Project (to which I'm new) I need to install GDAL version: x86_64 because whenever I try python manage.py migrate on my Django project I get the following error:
OSError: dlopen(/Users/name/lib/libgdal.dylib, 0x0006): tried:
'/Users/name/lib/libgdal.dylib' (mach-o file, but is an incompatible
architecture (have 'arm64', need 'x86_64'))....
I tried to switch the architecture of the terminal from arm64 to i386 and download it with the that architecture but I get the same error.
In my settings.py the libraries GDAL and GEOS variable are declared as follows:
GDAL_LIBRARY_PATH = '/opt/homebrew/opt/gdal/lib/libgdal.dylib'
GEOS_LIBRARY_PATH = '/opt/homebrew/opt/geos/lib/libgeos_c.dylib'
I searched and tried a lot of things, but nothing worked - have anyone had the same problem?
I successfully solved it with the answer from Ronald (M1 Mac - GDAL Wrong Architecture Error [Django])
I had to download both with a arm64 architecture, because my python was arch x86_64.
Related
It appears I'm unable to run the arm64 architecture in PyCharm and I don't understand why. I would really like to learn what I'm doing wrong.
Specs
I'm on a 2021 M1 MacBook Pro with macOs Monterey 12.6.2
PyCharm 2022.3.2 (Community Edition)
Runtime version: 17.0.5+1-b653.25 aarch64
For my virtual environments I use conda (miniforge3) version 4.14.0
When I run 'uname -m' in the PyCharm terminal it returns 'x86_64', however when I run the same command in zsh terminal I get 'arm64'. Both are executed in the conda 'base' environment and I would have expected the architectures to be the same.
What I've done
Downloaded PyCharm aarch64 (I was previously on x86_64), yielded the same result
Create specific arm64 and x86_64 conda environments, all return x86_64
Followed the steps in this thread arch x86_64 and arm64e is available but python3 is saying incompatible architecture on Mac M1
Thanks in advance for your help!
The issue is solved by deleting the current version of PyCharm and removing the left over ID directories as explained here https://www.jetbrains.com/help/pycharm/directories-used-by-the-ide-to-store-settings-caches-plugins-and-logs.html#logs-directory
After re-installing PyCharm it now works!
I was never able to install packages like pyzmq, scipy, numpy, and pandas because pip compiles these packages for arm64 instead of x86_64.
I only found out the cause of the error when I ran pip without realizing I had specific flags in my CFLAGS variable for a previous program I was compiling, as before I had just given up not understanding the errors and opted for the pip that came with python3.9 that did not give this error.
clang: error: unsupported option '-mlong-double-64' for target 'arm64-apple-macosx13.1.0' clang: error: the clang compiler does not support '-mtune=skylake
Is there any way to provide the correct target for pip, and what should it be for x86_64 intel OSX / MacOS?
I am trying to create a Pyinstaller on m1 mac for my django app.
When I run ./build.sh which contains
source .env/bin/activate
pyinstaller backend/manage.py -F \
--name "test" \
--icon='icon.ico' \
--add-data "backend/*:package" \
I get the following error
144 WARNING: Failed to collect submodules for 'django.contrib.gis.utils' because
importing 'django.contrib.gis.utils' raised: django.core.exceptions.ImproperlyConfigured:
Could not find the GDAL library (tried "gdal", "GDAL", "gdal3.4.0", "gdal3.3.0",
"gdal3.2.0", "gdal3.1.0", "gdal3.0.0", "gdal2.4.0", "gdal2.3.0", "gdal2.2.0"). Is GDAL
installed? If it is, try setting GDAL_LIBRARY_PATH in your settings.
In my settings.py I have
GDAL_LIBRARY_PATH = "/opt/homebrew/Cellar/gdal/3.5.2/lib/libgdal.dylib"
GEOS_LIBRARY_PATH = "/opt/homebrew/Cellar/geos/3.11.0/libgeos_c.1.17.0.dylib"
Amd in terminal
/opt/homebrew/opt/geos/lib/libgeos_c.dylib: Mach-O 64-bit dynamically linked shared library arm64
/opt/homebrew/Cellar/gdal/3.5.2/lib/libgdal.dylib: Mach-O 64-bit dynamically linked shared library arm64
If you are in MAC and Using Anaconda then
step 1: conda install -c conda-forge gdal
step 2: Set this on your Settings.py
GDAL_LIBRARY_PATH='/opt/anaconda3/lib/libgdal.dylib'
GEOS_LIBRARY_PATH='/opt/anaconda3/lib/libgeos_c.dylib'
(It worked for me)
I am recieving this error when installing and running
from ortools.constraint_solver import pywrapcp
after following this guide. https://developers.google.com/optimization/install/python/mac
I am using a 2019 MacBook Pro (V 12.4, Python 3.9.4), which is x86, and not M1. However, the error is regarding the module not being compatible with M1 Macs, which should not apply. All information available online is about the error regarding M1 Macs. Any help is appreciated!
ImportError: dlopen([path], 0x0002): tried: '[path]/my_env/lib/python3.9/site-packages/ortools/linear_solver/_pywraplp.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64h'))
M1 only wheel package have been named universal2 by pypa tools so any intel based mac currently pull it -> runtime issue.
On my way to fix our upload and release script, sorry for the inconvenience...
note: issue tracked in https://github.com/google/or-tools/issues/3436
note2: one workaround would be to download "locally" the correct wheel package then install it cd <you_download_dir>; python -m pip install --find-links=. ortools
try forcing the arch to x64_64.
For some reason, brew python tags aarch64 wheel as universal, and x86_64 as x86_64.
I'm trying install pycrypto on osx with easy_install and I'm getting the following error:
easy_install pycrypto
Searching for pycrypto
Reading http://pypi.python.org/simple/pycrypto/
Reading http://pycrypto.sourceforge.net
Reading http://www.pycrypto.org/
Reading http://www.amk.ca/python/code/crypto
Best match: pycrypto 2.3
Downloading http://ftp.dlitz.net/pub/dlitz/crypto/pycrypto/pycrypto-2.3.tar.gz
Processing pycrypto-2.3.tar.gz
Running pycrypto-2.3/setup.py -q bdist_egg --dist-dir /var/folders/3D/3D07iptvHZuzuYaeQDMFIU+++TI/-Tmp-/easy_install-00HgRU/pycrypto-2.3/egg-dist-tmp-BWGYsg
warning: GMP library not found; Not building Crypto.PublicKey._fastmath.
/usr/libexec/gcc/powerpc-apple-darwin10/4.2.1/as: assembler (/usr/bin/../libexec/gcc/darwin/ppc/as or /usr/bin/../local/libexec/gcc/darwin/ppc/as) for architecture ppc not installed
Installed assemblers are:
/usr/bin/../libexec/gcc/darwin/x86_64/as for architecture x86_64
/usr/bin/../libexec/gcc/darwin/i386/as for architecture i386
src/MD2.c:134: fatal error: error writing to -: Broken pipe
compilation terminated.
lipo: can't open input file: /var/folders/3D/3D07iptvHZuzuYaeQDMFIU+++TI/-Tmp-//ccoXuPRo.out (No such file or directory)
error: Setup script exited with error: command 'gcc-4.2' failed with exit status 1
I have this in my ~/.bash_profile to address this very issue:
# Set compile flags to not try to compile for PPC (no longer supported by xcode 4)
# (this is required for eg building pycrypto)
export ARCHFLAGS="-arch i386 -arch x86_64"
Yes, it's a result of installing Xcode 4. It tries to build for ppc, although Xcode 4 no longer has the relevant bits for that. See this question for ways round it: https://superuser.com/questions/259278/python-2-6-1-pycrypto-2-3-pypi-package-broken-pipe-during-build
xCode 5.1
ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install pycrypto
Looks like this got a little more difficult with OSX 10.9. Here's the additional stuff I did:
brew install libffi
If you see the warning about how it's installed "keg-only", that means homebrew did not link it, so you'll need to provide some more info with export PKG_CONFIG_PATH=/usr/local/opt/libffi/lib/pkgconfig. At that point the install blows up because by default OSX now dies on warning flags, so suppress that behavior as well:
export CFLAGS=-Qunused-arguments
export CPPFLAGS=-Qunused-arguments
Then you should be able to install with pip.