0

I am trying to use osgeo/gdal with Anaconda, but am failing to import osgeo or gdal when attempting to use a custom Anaconda environment.

I have created a new Anaconda environment that can utilize arcpy using the following command conda create -n arc1041 python=2.7.10 numpy=1.9.2 matplotlib=1.4.3 scipy=0.16.0 pandas pyparsing xlrd xlwt console_shortcut

However, when I open up the new environment, arc1041, with the anaconda prompt, I can't import osgeo and gdal. And, when I try to use Spyder as the IDE, I can't import gdal. I get an error message stating

 File "C:\Users\RDCERWAW\AppData\Local\Continuum\anaconda2\envs\arc1041\lib\site-packages\osgeo\__init__.py", line 21, in swig_import_helper
    _mod = imp.load_module('_gdal', fp, pathname, description)

ImportError: DLL load failed: The specified module could not be found.

Within the default Anaconda environment, I can import osgeo/gdal at both the command prompt and when using Spyder. I have appended the sys.paths from the default environment into the arc1041 environment, but this doesn't help.

Not sure how to proceed with running Anaconda/Spyder that has both ArcPy and osgeo/gdal capabilities.

  • Is the osgeo.gdal package a dependency of arc1041 or did you install it separately? – sgillies Dec 19 '17 at 18:32
  • I think there's a good chance you'll find a solution in stackoverflow.com/questions/30170468/…. The suggestions to install spyder in your arc1041 environment and then activate the environment look good to me. – sgillies Dec 19 '17 at 18:39
  • @sgillies I installed osgeo.gdal separately and used anaconda to install gdal. Also, when I activate arc1041 and start python, I am unable to import gdal, even though conda install gdal detects gdal within the arc1041 environment. – user44796 Dec 19 '17 at 21:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.