简体   繁体   中英

(M1 Mac) Geodjango GDAL: mach-o, but wrong architecture

I am trying to get GeoDjango running on mac os and have hit a problem with GDAL.

I have downloaded and installed GDAL without problem (Gdal Complete Binary) also installed from homebrew too.

Unfortunately when i was installed gdal with homebrew django can't find the gdal and throws gdal did not find error, after that. I installed from KyngChaos GeoDjango Binary django find gdal but now throws that;

OSError: dlopen(/Library/Frameworks/gdal.framework/gdal, 6): no suitable image found.  Did find:
    /Library/Frameworks/gdal.framework/gdal: mach-o, but wrong architecture
    /Library/Frameworks/gdal.framework/gdal: mach-o, but wrong architecture
    /Library/Frameworks/GDAL.framework/Versions/3.1/GDAL: mach-o, but wrong architecture
    /Library/Frameworks/GDAL.framework/Versions/3.1/GDAL: mach-o, but wrong architecture

I think the Kyngchaos build not compaitable with arm platform

Any help would be much appreciated.

Django Version: 3.0 also tried 3.2
Gdal Version: 3.2/3.1/2.4 All of them tried
Python Version: 3.8
Postgresql Version: 13
Postgis/Geos installed
gdal-config --libs:

-L/opt/homebrew/Cellar/gdal/3.2.2_3/lib -lgdal
brew info gdal

which should give you something like:

/opt/homebrew/Cellar/gdal/3.2.2_3/lib/libgdal.dylib

put that into your GDAL_LIBRARY_PATH.

From here, you can debug it further by putting a break point in your exception's line.

Find the paths of gdal and geos

find /opt -name "libgdal.dylib" -print 2>/dev/null
find /opt -name "libgeos_c.dylib" -print 2>/dev/null

Copy the output for gdal and geos (might be more than one, pick one of each)

/opt/homebrew/Cellar/gdal/3.6.2/lib/libgdal.dylib
/opt/homebrew/Cellar/geos/3.11.1/lib/libgeos_c.dylib

Put it in the settings.py file

Put it in the DJANGO settings file, the default one is here but your milage may vary:

mysite
 ├── manage.py
 └── mysite
      ├── __init__.py
      └── settings.py

Bottom of the file:

# mysite/mysite/settings.py
GDAL_LIBRARY_PATH="/opt/homebrew/Cellar/gdal/3.6.2/lib/libgdal.dylib"
GEOS_LIBRARY_PATH="/opt/homebrew/Cellar/geos/3.11.1/lib/libgeos_c.dylib"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM