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 geodjango locally before putting it in the cloud. I have been working with Django for a little while now on my local machine with the SQLite DB, but since the next project will partly be based on coordinate based data I wanted to setup the right environment.
Import note: I've installed mini-conda to run in a seperate environment. I do activate this environment "development" when I work though
I've tried to follow most of the geodjango information/tutorials online, but can't get it to work. What I've done (mostly followed this: https://docs.djangoproject.com/en/2.0/ref/contrib/gis/install/#windows):
After all of this I created a new django project and in settings.py I've added some parts:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.gis',
'nameOfMyApp',
]
I've also got this in settings.py:
DATABASES = {
'default': {
'ENGINE': 'django.contrib.gis.db.backends.postgis',
'NAME': 'geodjango',
'USER': '****',
'PASSWORD': '****',
'HOST': 'localhost',
}
}
# FOR GEODJANGO
POSTGIS_VERSION = (2, 4, 3)
When I try to set up the database in django I run (in the right folder):
python manage.py makemigrations
I get the following error:
django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library (tried "gdal202", "gdal201", "gdal20", "gdal111", "gdal110", "gdal19"). Is GDAL installed? If it is, try setting GDAL_LIBRARY_PATH in your settings.
I've tried to fix that, but nothing seems to work. Can anybody give me some help in setting this all up locally?
Update 7-3-2018:
Now I get the following error:
OSError: [WinError 126] The specified module could not be found
(while the .dll is there...)
I have found the following to work for windows:
python
to check if your python is 32 or 64 bit.C:\OSGeo4W
or C:\OSGeo4W64
:
Make sure the following is included in your settings.py
:
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']
Run python manage.py check
to verify geodjango is working correctly.