Getting GIS Working - possible kernel32 problem

264 views
Skip to first unread message

Robin St.Clair

unread,
Oct 25, 2013, 9:40:24 AM10/25/13
to django...@googlegroups.com
Hi

I am working with a project started by somebody else.It uses GIS. I have installed GDAL and OpenGeo4W, plus the C++ runtime.

I have the following included in the path
  • C:\Python27\;C:\Python27\Scripts;C:\Python27\Tools\Scripts\;C:\Python27\lib\site-packages;C:\gdalwin32-1.6\bin;C:\usr\bin;C:\Program Files\GDAL;C:\ms4w\Apache\cgi-bin;C:\OSGeo4W\bin;

and the following environment variables are set
  • GDAL_DATA = %OSGEO4W_ROOT%\share\gdal
  • GDAL_DRIVER_PATH = C:\Program Files\GDAL\gdalplugins
  • GEOS_LIBRARY_PATH=C:\OSGeo4W\lib
  • OSGEO4W_ROOT=C:\OSGeo4w
  • PROJ_LIB=%OSGEO4W_ROOT%\share\proj
  • PYTHON_ROOT=C:\Python27

Originally this development started on a linux box, I am using Vista SP2.

My database is PostgreSQL 9.3, I have installed the PostGIS options and set up a normal and a GIS database.

When I start runserver through Pycharm, I get the errors at the bottom of this post.

It appears, and I might be wrong as I'm not mega experienced with this, that django/python can't find kernell32. This is used by the C library.

Here is what I have found from thr debugger
self = unable to get repr for class <class 'ctypes.WinDLL'
handle=None
mode=0
name='kernel32'
Funcptr = <class 'ctypes.WinDLL'>

Can somebody please point me in the correct direction, I'm banging my head

Thanks

Robin


GEODJANGOGeos, TRACEBACK

"C:\Program Files\JetBrains\PyCharm 3.0.1\bin\runnerw.exe" C:\Python27\python.exe "C:\Program Files\JetBrains\PyCharm 3.0.1\helpers\pycharm\django_manage.py" runserver 8888 "C:/Users/Robin St.Clair/Desktop/CheckBuild"

Validating models...

Unhandled exception in thread started by <bound method Command.inner_run of <django.contrib.staticfiles.management.commands.runserver.Command object at 0x02E17EB0>>

Traceback (most recent call last):

  File "C:\Python27\lib\site-packages\django\core\management\commands\runserver.py", line 92, in inner_run self.validate(display_num_errors=True)  

  File "C:\Python27\lib\site-packages\django\core\management\base.py", line 280, in validate num_errors = get_validation_errors(s, app)

  File "C:\Python27\lib\site-packages\django\core\management\validation.py", line 35, in get_validation_errors for (app_name, error) in get_app_errors().items():

  File "C:\Python27\lib\site-packages\django\db\models\loading.py", line 166, in get_app_errors self._populate()

  File "C:\Python27\lib\site-packages\django\db\models\loading.py", line 72, in _populate self.load_app(app_name, True)

  File "C:\Python27\lib\site-packages\django\db\models\loading.py", line 96, in load_app models = import_module('.models', app_name)

  File "C:\Python27\lib\site-packages\django\utils\importlib.py", line 35, in import_module __import__(name)

  File "C:\Python27\lib\site-packages\mptt\models.py", line 14, in <module> from mptt.fields import TreeForeignKey, TreeOneToOneField, TreeManyToManyField

  File "C:\Python27\lib\site-packages\mptt\fields.py", line 42, in <module> from south.modelsinspector import add_introspection_rules

  File "C:\Python27\lib\site-packages\south-0.8.2-py2.7.egg\south\modelsinspector.py", line 463, in <module> import south.introspection_plugins

  File "C:\Python27\lib\site-packages\south-0.8.2-py2.7.egg\south\introspection_plugins\__init__.py", line 5, in <module> import south.introspection_plugins.geodjango

  File "C:\Python27\lib\site-packages\south-0.8.2-py2.7.egg\south\introspection_plugins\geodjango.py", line 14, in <module> from django.contrib.gis.db.models.fields import GeometryField

  File "C:\Python27\lib\site-packages\django\contrib\gis\db\models\__init__.py", line 5, in <module> from django.contrib.gis.db.models.aggregates import *

  File "C:\Python27\lib\site-packages\django\contrib\gis\db\models\aggregates.py", line 2, in <module> from django.contrib.gis.db.models.sql import GeomField

  File "C:\Python27\lib\site-packages\django\contrib\gis\db\models\sql\__init__.py", line 2, in <module> from django.contrib.gis.db.models.sql.query import GeoQuery

  File "C:\Python27\lib\site-packages\django\contrib\gis\db\models\sql\query.py", line 4, in <module> from django.contrib.gis.db.models.fields import GeometryField

  File "C:\Python27\lib\site-packages\django\contrib\gis\db\models\fields.py", line 4, in <module> from django.contrib.gis import forms

  File "C:\Python27\lib\site-packages\django\contrib\gis\forms\__init__.py", line 2, in <module> from django.contrib.gis.forms.fields import GeometryField

  File "C:\Python27\lib\site-packages\django\contrib\gis\forms\fields.py", line 8, in <module> from django.contrib.gis.geos import GEOSException, GEOSGeometry

  File "C:\Python27\lib\site-packages\django\contrib\gis\geos\__init__.py", line 6, in <module> from django.contrib.gis.geos.geometry import GEOSGeometry, wkt_regex, hex_regex

  File "C:\Python27\lib\site-packages\django\contrib\gis\geos\geometry.py", line 16, in <module> from django.contrib.gis.geos.coordseq import GEOSCoordSeq

  File "C:\Python27\lib\site-packages\django\contrib\gis\geos\coordseq.py", line 9, in <module> from django.contrib.gis.geos.libgeos import CS_PTR

  File "C:\Python27\lib\site-packages\django\contrib\gis\geos\libgeos.py", line 58, in <module> lgeos = CDLL(lib_path)

  File "C:\Python27\lib\ctypes\__init__.py", line 365, in __init__ self._handle = _dlopen(self._name, mode)

WindowsError: [Error 126] The specified module could not be found






Sam Lai

unread,
Oct 25, 2013, 7:40:13 PM10/25/13
to django-users
Can you try running 'python.exe manage.py runserver' outside of
PyCharm, i.e. in the Command Prompt/PowerShell?

I've got a similar setup, although on Windows 7, and it works. Instead
of setting environment variables, I added the following parameters
into my settings.py to indicate the location of the GEOS DLLs -

GEOS_LIBRARY_PATH = os.sep.join((PROJECT_PATH, '..', 'Scripts', 'geos_c.dll'))
GDAL_LIBRARY_PATH = os.sep.join((PROJECT_PATH, '..', 'Scripts', 'gdal110.dll'))

Find those two files on your system (I didn't install GDAL or OSGeo4W
so I can't tell you where) and set the above parameters in settings.py
and see how you go.
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e7019f09-9c56-405d-9427-22d3988bad21%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
Reply all
Reply to author
Forward
0 new messages