I'm super new on python and i am just deploying an open source app that was done in python and I'm getting a:
ImportError: cannot import name DataSource on from django.contrib.gis.gdal import DataSource
However, this is just fine:
impo开发者_如何学Gort django.contrib.gis.gdal
My current environment setup is:
- Linux
- Python 2.7 installed in /opt/python
- GDAL installed via easy_install like so '/opt/python/bin/easy_install GDAL'
- Doing #3 looks like it got installed here: '/opt/python/lib/python2.7/site-packages/GDAL-1.7.1-py2.7.egg-info'
Could someone guide me here please?
If i could do import django.contribs.gis.gdal
, how come DataSource
cannot be imported? I assume DataSource
is also part of the GDAL library?
Do you have python-gdal
installed? It seems that django.contrib.gis.gdal
only exposes the DataSource
class if it is installed. At least on Ubuntu, installing python-django
didn't install python-gdal
by default.
EDIT: as noted in the comments below, you did have it installed, but the module responsible for locating it, django/contrib/gis/gdal/libgdal.py
did not find it. If you peek in the source for that module (e.g. http://code.djangoproject.com/browser/django/branches/gis/django/contrib/gis/gdal/libgdal.py?rev=8012), there's a GDAL_LIBRARY_PATH
setting that I think you could use to help Django find it.
精彩评论