Reputation: 63
I'm beginning on programming with python. I just finished to install all the requirements to start a new web project with django and OSGEO4W.
I try to run "manage.py check" and it returns this error message:
"django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library >(tried "gdal202", "gdal201", "gdal20", "gdal111", "gdal110", "gdal19", >"GDAL2.4.0"). Is GDAL installed? If it is, try setting GDAL_LIBRARY_PATH in >your settings."
First, I installed OSGEO4W 32 bits (because my python is in 32 bits) Then, I added an environment variable, there it is:
GDAL_DATA = C:\OSGeo4W\share\gdal
I believe that all is installed correctly because when I run "gdalinfo --version" in the command line tool it returns me:
GDAL 2.4.0, released 2018/12/14
I already tested the existing topics, but I still can't resolve my problem..
I tried to change the libgdal.py file by adding some "gdal240", "gdal24", and so on, but nothing changes.
I tried to set the variable as the message says as:
GDAL_LIBRARY_PATH = os.getenv('GDAL_DATA')
But this time, I get this message:
OSError: [WinError 126] The specified module could not be found
All I did is follow this tutorial to setup all these on windows:
https://docs.djangoproject.com/en/2.1/ref/contrib/gis/install/#windows
I don't know if you need more information, please ask and i'll provide you what you need.
Upvotes: 2
Views: 2105
Reputation: 379
I have used these settings and it worked.
import os
if os.name == 'nt':
import platform
OSGEO4W = r"C:\OSGeo4W"
if '64' in platform.architecture()[0]:
OSGEO4W += "64"
assert os.path.isdir(OSGEO4W), "Directory does not exist: " + OSGEO4W
os.environ['OSGEO4W_ROOT'] = OSGEO4W
os.environ['GDAL_DATA'] = OSGEO4W + r"\share\gdal"
os.environ['PROJ_LIB'] = OSGEO4W + r"\share\proj"
os.environ['PATH'] = OSGEO4W + r"\bin;" + os.environ['PATH']
GDAL_LIBRARY_PATH = r'C:\OSGeo4W64\bin\gdal300.dll'
Upvotes: 1