【问题标题】:django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library - m1 macdjango.core.exceptions.ImproperlyConfigured:找不到 GDAL 库 - m1 mac
【发布时间】:2022-10-04 22:19:56
【问题描述】:

我正在尝试在 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.

在我的 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

【问题讨论】:

    标签: python django pyinstaller apple-m1


    【解决方案1】:

    如果您在 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'
    

    (它对我有用)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-02-15
      • 2019-09-01
      • 2018-07-24
      • 2022-07-13
      • 1970-01-01
      • 1970-01-01
      • 2021-10-04
      • 2022-07-11
      相关资源
      最近更新 更多