I am trying to run some Python code using the Python window in ArcGIS 10.1 that uses both the arcpy and gdal modules. However, when I try and import the gdal module I get an error:

ImportError: No module named osgeo

Obviously it can't find the module, so I have added my main python site-packages directory to the sys.path list:


However, when I try and run import osgeo or from osgeo import gdal I get the following error:

Runtime error 
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Python27\lib\site-packages\osgeo\__init__.py", line 21, in <module>
    _gdal = swig_import_helper()
  File "C:\Python27\lib\site-packages\osgeo\__init__.py", line 17, in swig_import_helper
    _mod = imp.load_module('_gdal', fp, pathname, description)
ImportError: DLL load failed: %1 is not a valid Win32 application.

I've found various resources on the internet that seem to talk about similar problems (for example this question and this forum post, but they seem to be out-of-date (ie. not using ArcGIS 10.1) or not asking quite the same question.

Of course, importing osgeo from a normal non-Arc Python window works fine, and I have compared sys.path and os.environ['PATH'] between the scripts and updated them so that they are the same, and it doesn't seem to fix the problem.

Does anyone have any idea how I can get this to work?

  • I have heard stories of people getting GDAL to work in the ArcGIS python interface before. A few questions: Which method did you use to install GDAL and are you sure you have the correct windows bindings installed and correctly setup? And have you installed the python bindings to the ArcGIS python install? Aug 14, 2012 at 12:03
  • It looks like you have another version (2.7) of Python installed in addition to the version (2.6) installed by ArcGIS 10. Did you install GDAL for 2.6 as well or are you trying to point it to the version installed for 2.7? Is your 2.7 install a 64-bit installation? Aug 14, 2012 at 13:37
  • @Jason: I'm using ArcGIS 10.1, which according to gis.stackexchange.com/questions/22271/… uses Python 2.7. Do you know if that is correct?
    – robintw
    Aug 14, 2012 at 17:22
  • 1
    @Robintw there are numerous ways to install GDAL for python. Perhaps you could link me to the executable you used and how you set it up? Aug 14, 2012 at 19:33
  • 2
    I've just managed to solve the question - I managed to miss reading the bit above where @Jason asked if I was using a 64-bit installation of Python 2.7. The answer is that my main Python 2.7 install is 64-bit, but Arc's install is 32-bit, so I needed to install a 32-bit version of GDAL, and now it works fine. Thanks everyone - I'll add my final solution as an answer.
    – robintw
    Aug 15, 2012 at 14:18

1 Answer 1


@robintw has confirmed it in the comments.

ImportError: DLL load failed: %1 is not a valid Win32 application.

From the error, it would seem that your Python 2.7 installation is 64-bit. You'll have to install the 32-bit version of Python and GDAL.

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.