[GIS] Importing OGR from OSGEO Issues

ogrosgeopython

I am trying to run:

from osgeo import ogr

and I get:

Traceback (most recent call last):
File "", line 1, in
from osgeo import ogr
File "C:\Python27\ArcGIS10.2\lib\site-packages\osgeo__init__.py", line 21, in
_gdal = swig_import_helper()
File "C:\Python27\ArcGIS10.2\lib\site-packages\osgeo__init__.py", line 13, in swig_import_helper
import _gdal
ImportError: No module named _gdal

So obviously, it's finding the osgeo mod, but what the heck is the _gdal mod? A simple search within my Python paths, shows that I have a module called gdal, but not one with the underscore. Seems like a small issue?

Best Answer

I had this problem today as I was trying to install GDAL on a new machine. I got the error above after the install appeared to work and I was trying to start using it.

The best solution turned out to be starting again and installing from Christoph Gohlke's unofficial binaries: http://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal