I am using python 3.4, postgres 9.3.5, Windows 7.
I followed this to try to get GeoDjango working: https://docs.djangoproject.com/en/dev/ref/contrib/gis/install/#windows
When I try to add the django.contrib.gis to installed apps (in pycharm), or when I try to run
the below is the traceback.
However, in this directory C:\Python34\Lib\site-packages\django\contrib\gis\geos there is geometry.py (which as the class GEOSGeometry in it) and error.py (which has the class GEOSException in it).
When I run this in the python shell, it does not throw any errors:
>>> from django.contrib.gis.geos.error import GEOSException
Thanks for any thought on what the issue may be. A bunch of other traceback, then:
File "C:\Python34\lib\site-packages\django\contrib\gis\forms\fields.py", line
8, in <module>
from django.contrib.gis.geos import GEOSException, GEOSGeometry
ImportError: cannot import name 'GEOSException'
UPDATE I found some info that suggested that I should update the project setting:
GEOS_LIBRARY_PATH = r'C:\Program Files\OSGeo4W64\bin\geos_c.dll'
That worked, but now I get a WinError 126
File "C:\Python34\lib\site-packages\django\contrib\gis\forms\fields.py", line
8, in <module>
from django.contrib.gis.geos import GEOSException, GEOSGeometry
File "C:\Python34\lib\site-packages\django\contrib\gis\geos\__init__.py", line
9, in <module>
from .libgeos import geos_version, geos_version_info # NOQA: flake8 detects
only the last __all__
File "C:\Python34\lib\site-packages\django\contrib\gis\geos\libgeos.py", line
61, in <module>
lgeos = CDLL(lib_path)
File "C:\Python34\lib\ctypes\__init__.py", line 351, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found
I am not clear on what module it is that cannot be found, nor how to fix it.
I was able to fix the problem. See what I did here:
Django forum with how I fixed it
As for the
win 126
error:I am not sure exactly what helped finally fix it but:
GEOS_LIBRARY_PATH
ofC:\program files\OSGeo4W\bin\geos_c.dll
but I should have added:
C:\OSGeo4W\bin\geos_c.dll
Now, I can just delete the
GEOS_LIBRARY_PATH
from the project settings and things still work, so I guess it must have been the 64 bit vs 32 bit issue, or the path issue.