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

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Aug 30, 2013 at 9:22
1
  • 1
    You should check the steps outlined in the blog link in this answer Commented 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.

answered Apr 22, 2014 at 14:22
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. Commented 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

answered Aug 30, 2013 at 10:27
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.. Commented 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

answered Dec 2, 2014 at 8:29
-2

Have you tried:

try:
 from osgeo import ogr
except ImportError:
 import ogr
answered Jul 19, 2016 at 17:43

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.