1

I am trying to import gdal modules from osgeo installed in my win64x machine but I get the following error:

Traceback (most recent call last):
File "", line 1, in
from osgeo import ogr
ImportError: No module named osgeo

I am using the python shell from arcgis 10.1 that comes with python 2.7.2

1
  • 1
    You should check the steps outlined in the blog link in this answer
    – Martin
    Aug 30, 2013 at 9:33

4 Answers 4

2

Python IDE which is installed with ArcGiS can't use GDAL modules. You have few options:

  • Install QGis and use python shell in QGis,
  • Install new Python IDE and again install GDAL libraries,
  • Install development enviroment like Eclipse, there you can set python interpreter and connect libraries installed somwhere else.

I think that first option will be easiest and fastest.

1
  • 2
    That isn't true, that ArcGIS Python IDE can't use GDAL module. You can use official ESRI GDAL Bindings for Python here, or download core of GDAL here, but then you have to setup few things manually - here is the manual.
    – david_p
    Sep 26, 2014 at 8:31
1

The python shell of ArcGIS is probably using its own python installation (C:\Python27\ArcGIS10.1) while gdal is installed with the OSGEO python version (C:\OSGeo4W\apps\python27).

I´m not sure if you can get OGR running in ArcGIS python shell. You can certainly get both running together in external python scripts!

Maybe you can find further help here, even though OGR seems not to be included:

ArcGIS Python Bindings for GDAL 1.8

1
  • 1
    I have my OGR accessible from within Arcmap, so it can certainly be done. You have a point though, it is important to note which installation it applies to since Arcmap uses it's own..
    – Martin
    Aug 30, 2013 at 11:27
1

You can tell python where to look for additional libraries (e.g. GDAL) by adding their location to the PYTHONPATH.

To do this you will need privileges on your machine to edit system variables and know the exact location of your GDAL python package.

The process of changing the PYTHONPATH is outlined here: Add to PYTHONPATH on Windows 7

-2

Have you tried:

try:
    from osgeo import ogr
except ImportError:
    import ogr

Your Answer

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

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