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):
- Download and install the latest (10.3) PostgreSQL setup from https://www.enterprisedb.com/downloads/postgres-postgresql-downloads
- After installation I also installed used the Application Stack Builder to install PostGis
- I've installed OSGeo4W from https://trac.osgeo.org/osgeo4w/
- I've created a batch script as described on the geodjango website (https://docs.djangoproject.com/en/2.0/ref/contrib/gis/install/#windows) and ran it as administrator (except for the part where it sets the path to python, cause python was already in there since I've been using python for a while now)
- I've tried some command in psql shell and I think I've created a database with name: geodjango, username: **** and pass: ****.
- I don't know if I have given the geodjango user all priveleges, but I suspect so.
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...)
See Question&Answers more detail:
os