[Django]-Django 1.6b gis import error

5👍

Make sure you have installed the Geospatial libraries. I have tested Python 3.3.2 and Django 1.6 beta 2 in a virtual env. The import from contrib.gis works fine.

>>> import django
>>> django.VERSION
(1, 6, 0, 'beta', 2)
>>> from django.contrib.gis.db import models as geomodels

Note that contrib.localflavor has been removed from Django 1.6.

>>> from django.contrib.localflavor.us.models import USStateField
Traceback (most recent call last):
  File "<console>", line 1, in <module>
ImportError: No module named 'django.contrib.localflavor'

You can install the django-localflavor package with:

pip install django-localflavor

then change your import to:

from localflavor.us.models import USStateField

1👍

I have just faced the same problem. Unfortunately, ImportError: cannot import name GEOSException is not the best error message when Django cannot find GEOS library.

I have Django 1.6.1 final and Python 3.3 too. OS is Windows 7 64-bit. Python, GEOS are x86-64 too.

As recommended at Django docs, the line:

GEOS_LIBRARY_PATH = r'C:\Program Files\OSGeo4W64\bin\geos_c.dll'

in my Django project settings solved this issue.

Leave a comment