django.core.exceptions.ImproverlyConfigure:找不到GDAL库-m1-mac



我正试图在m1 mac上为我的django应用程序创建一个Pyinstaller。

当我跑步的时候/build.sh,包含

source .env/bin/activate
pyinstaller backend/manage.py -F 
--name "test" 
--icon='icon.ico' 
--add-data "backend/*:package" 

我得到以下错误

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.

在我的设置中.py我有

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

/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

如果您在MAC和使用Anaconda,则
步骤1:conda install -c conda-forge gdal
第2步:在Settings.py
上设置

GDAL_LIBRARY_PATH='/opt/anaconda3/lib/libgdal.dylib'
GEOS_LIBRARY_PATH='/opt/anaconda3/lib/libgeos_c.dylib'

(对我有效(

最新更新