Search code examples
pythondjangogdalgeodjango

geodjango error importing LayerMapping


Setup:

Windows 10

Python 2.7

Django 1.11

Standalone GDAL install gdal-202-1911-core.msi from gisinternals

QGIS version 3

PostgreSQL 9.5 with Postgis 2.3

Environmental Variables

ERROR

from django.contrib.gis.utils import LayerMapping
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
ImportError: cannot import name LayerMapping

I can open up the layermapping.py, the file is there. There needs to be something wrong with my setup here. what should I be doing to correctly import LayerMapping, why is this happening


Solution

  • Your geos/GDAL installation is probably broken. Follow the instructions in this answer for properly installing geodjango on windows.