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
-
1You should check the steps outlined in the blog link in this answerMartin– Martin2013年08月30日 09:33:06 +00:00Commented Aug 30, 2013 at 9:33
4 Answers 4
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.
-
2
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:
-
1I 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– Martin2013年08月30日 11:27:18 +00:00Commented Aug 30, 2013 at 11:27
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
Have you tried:
try:
from osgeo import ogr
except ImportError:
import ogr