GeoDjango on Windows: “Could not find the GDAL library” / “OSError: [WinError 126] The specified module could not be found”

后端 未结 8 1557
青春惊慌失措
青春惊慌失措 2020-11-28 06:58

I\'ve been trying to setup my windows computer such that I can have a local postgreSQL with PostGIS extension. With this installed I hope to be able to create a project with

8条回答
  •  忘掉有多难
    2020-11-28 07:55

    For Microsoft Windows 10 & Python3.6.8, I installed GDAL 2.3.3 from Unofficial Windows Binaries for Python Extension Packages, modified libgdal.py adding gdal203 in the lib_names list env\Lib\site-packages\django\contrib\gis\gdal\libgdal.py.

    Finally, added osgeo and proj to the PATH, and set the GDAL_LIBRARY_PATH as below (beginning of settings.py):

    os.environ['PATH'] = os.path.join(BASE_DIR, r'env\Lib\site-packages\osgeo') + ';' + os.environ['PATH']
    
    os.environ['PROJ_LIB'] = os.path.join(BASE_DIR, r'env3\Lib\site-packages\osgeo\data\proj') + ';' + os.environ['PATH']
    
    GDAL_LIBRARY_PATH = os.path.join(BASE_DIR, r'env\Lib\site-packages\osgeo\gdal203.dll') 
    

    In this case, env is my Python environment.

提交回复
热议问题