我在Windows上安装了GEODjango
gdal
。但我有一个错误:
django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library (tried "gdal201", "gdal20", "gdal111", "g
dal110", "gdal19"). Is GDAL installed? If it is, try setting GDAL_LIBRARY_PATH in your settings.
之后,我已通过将此行插入GDAL_LIBRARY_PATH
来配置setting.py
:
GDAL_LIBRARY_PATH = 'C:\Users\User\Desktop\FeedGit\env\Lib\site-packages\osgeo\gdal.py'
得到了这个错误:
File "C:\Users\User\Desktop\FeedGit\env\lib\site-packages\django\contrib\gis\gdal\libgdal.py", line 49, in <module>
lgdal = CDLL(lib_path)
File "c:\python27\Lib\ctypes\__init__.py", line 366, in __init__
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 193] %1 is not a valid Win32 application
我认为这是Windows x64和Windows x32之间的错误。这是我的python版本:
Python 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:19:30) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
我的电脑正在运行Windows 7 64位。
如何解决此错误?
答案 0 :(得分:0)
解决:安装 OSGeo4W 32位并配置:
GDAL_LIBRARY_PATH = r'C:\OSGeo4W\bin\gdal202.dll'
settings.py 中的。感谢@MaheshKaria