2

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?

6
  • You need to include the path to your OSGEO install somewhere. Try import sys then sys.path.append(Path_to_install) prior to from osgeo import gdal. Aug 25, 2014 at 2:00
  • look into this directory (if it exists) just for fun: C:\Python27\lib\site-packages\osgeo Aug 25, 2014 at 12:43
  • In my C:\Python27\ArcGIS10.2\Lib\site-packages\osgeo location theres a 'gdal' file but it's not the '_gdal' one that the error throws. And "'C:\\Python27\\ArcGIS10.2\\lib\\site-packages'" is within my sys.path and that's where the osgeo folder is. So python already is pointed to it.
    – Dave
    Aug 30, 2014 at 21:58
  • curious if you solved this. was gdal installed as standalone or with a python distro (anaconda, xy, etc..)? Sep 12, 2014 at 12:23
  • I'm interested: Could you solve this?
    – user81683
    Aug 30, 2016 at 14:28

1 Answer 1

1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.