简体   繁体   中英

django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library - m1 mac

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)

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