GeoDjango 在 Windows 10 中找不到 GDAL 库 [英] GeoDjango could not find GDAL library in Windows 10
问题描述
我在 Windows 10 上使用 Django 11.4,但在尝试迁移模型时遇到了问题.我收到此错误:
I am using Django 11.4 on Windows 10 and I am having problems when I try and migrate my models. I receive this error:
django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library (tried "gdal201", "gdal20", "gdal111", "gdal110", "gdal19")
我遵循了 GeoDjango 的安装说明(https://docs.djangoproject.com/en/1.11/ref/contrib/gis/install/),但我仍然遇到问题.我在此错误中发现的所有内容都表明要更改系统环境变量.
I followed GeoDjango's installation instructions (https://docs.djangoproject.com/en/1.11/ref/contrib/gis/install/), but I am still having trouble. Everything I have found on this error says to change the system environment variables.
我安装了 OSGe4W
并添加了 GDAL_DATA = C:OSGeo4Wsharegdal
以及 PROJ_LIB= C:OSGeo4Wshareproj代码>.
I installed OSGe4W
and added GDAL_DATA = C:OSGeo4Wsharegdal
as well as PROJ_LIB= C:OSGeo4Wshareproj
.
我不确定还可以尝试什么,如果有更多见解,我将不胜感激.
I am not sure what else to try and I would appreciate any more insight.
推荐答案
我通过编辑 %PYTHONPATH%Libsite-packagesdjangocontribgisgdal 中的 libgdal.py 文件并添加 str('gdal202') 到第 26 行,因此显示为:
I fixed this by editing the libgdal.py file in %PYTHONPATH%Libsite-packagesdjangocontribgisgdal and adding str('gdal202') to line 26 so it reads:
lib_names = [str('gdal201'), str('gdal202'), str('gdal111'), str('gdal110'), str('gdal19')]
根据您使用的 GDAL 版本,您可能需要添加不同的版本号.
Depending on what version of GDAL you are using, you may need to add a different version number.
这篇关于GeoDjango 在 Windows 10 中找不到 GDAL 库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!