本文介绍: Is GDAL installed? If it is, try setting GDAL_LIBRARY_PATH in your settings 报错解决

1. 参考

https://docs.djangoproject.com/en/5.0/ref/contrib/gis/install/#macos

2. 问题描述

苹果系统 Mac 中搭建 GeoDjango 开发环境时出现以下报错:

  File "*.venv/lib/python3.8/site-packages/django/contrib/gis/gdal/libgdal.py", line 60, in <module>
    raise ImproperlyConfigured(
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.

3. 解决步骤

3.1. 安装依赖包

sudo port install postgresql13-server
sudo port install geos
sudo port install proj6
sudo port install postgis3
sudo port install gdal
sudo port install libgeoip
pip install GDAL=="$(gdal-config --version).*" 

3.2. 配置 GDAL_LIBRARY_PATH

sudo find / -name "libgdal*"

找到 libgdal.dylib 的路径

/opt/local/lib/libgdal.dylib

settings.py 中添加以下代码:

GDAL_LIBRARY_PATH = '/opt/local/lib/libgdal.dylib'

3.3. 配置 GEOS_LIBRARY_PATH

sudo find / -name "libgeos_c*"

找到 libgeos_c.dylib 的路径

/opt/local/lib/libgeos_c.dylib

settings.py 中添加以下代码:

GEOS_LIBRARY_PATH = '/opt/local/lib/libgeos_c.dylib'

原文地址:https://blog.csdn.net/weixin_43275654/article/details/135720100

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。

如若转载,请注明出处:http://www.7code.cn/show_61061.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除!

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注