GeoDjango在Windows 10中找不到GDAL库 [英] GeoDjango could not find GDAL library in Windows 10

查看:603
本文介绍了GeoDjango在Windows 10中找不到GDAL库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在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/zh-CN/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:\OSGeo4W\share\gdalPROJ_LIB= C:\OSGeo4W\share\proj.

I installed OSGe4W and added GDAL_DATA = C:\OSGeo4W\share\gdal as well as PROJ_LIB= C:\OSGeo4W\share\proj.

我不确定还可以尝试什么,我将不胜感激.

I am not sure what else to try and I would appreciate any more insight.

推荐答案

我通过在%PYTHONPATH%\ Lib \ site-packages \ django \ contrib \ gis \ gdal中编辑libgdal.py文件并添加str(' gdal202')移至第26行,因此其内容为:

I fixed this by editing the libgdal.py file in %PYTHONPATH%\Lib\site-packages\django\contrib\gis\gdal 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆