1

I am trying to get GDAL running under the following environment:

  • Win 10
  • Miniconda3 (this is just Anaconda with fewer modules loaded by default)
  • Python 3.6.6

I installed GDAL with conda install -c conda-forge gdal

When I try to import osgeo.gdal, I get this error:

(base) C:\Users\askov>conda activate geoprocessing

(geoprocessing) C:\Users\askov>python
Python 3.6.6 |Anaconda, Inc.| (default, Jun 28 2018, 11:27:44) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from osgeo import gdal
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\askov\AppData\Local\conda\conda\envs\geoprocessing\lib\site-packages\osgeo\__init__.py", line 21, in <module>
    _gdal = swig_import_helper()
  File "C:\Users\askov\AppData\Local\conda\conda\envs\geoprocessing\lib\site-packages\osgeo\__init__.py", line 17, in swig_import_helper
    _mod = imp.load_module('_gdal', fp, pathname, description)
  File "C:\Users\askov\AppData\Local\conda\conda\envs\geoprocessing\lib\imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "C:\Users\askov\AppData\Local\conda\conda\envs\geoprocessing\lib\imp.py", line 343, in load_dynamic
    return _load(spec)
ImportError: DLL load failed: The specified module could not be found.

I saw some articles (for example) suggesting I install GDAL from GIS Internals, which I did. The GIS Internals version I used was gdal-203-1900-x64-core.msi. I also updated the PATH, GDAL_DATA, and GDAL_DRIVER_PATH, but that had no effect. I checked those variables in my Conda environment, and they are different from the system settings. Even after I manually set them (via the DOS set command), I get the same result.

Another article suggested installing the krb5 module, which I installed via conda, with no change in the result.

How can I get gdal working in from a clean python environment (i.e.: not via QGIS or OSGeo4W)?

  • @Luke - Thanks for the tip, but I get the same result with conda create -c conda-forge -n gp "python=3" "gdal=2". The environment's path is super-long, and includes, in order, several conda folders (including the folder with the GDAL executables), QGIS and GIS-Internals folders. The GDAL_DATA env variable is <conda_path>\conda\conda\envs\gp\Library\share\gdal. The GDAL_DRIVER_PATH env variable is not set. Any suggestions on what to try next? Thanks! – David A Aug 1 '18 at 18:16
1

Have you tried installing GDAL using the binary wheels from https://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal ?

On a normal python installation you would simply use pip to install it from command line:

cd "C:\Path\To\Python\Scripts"

pip install "insert gdal binary wheel name here" 

Your Answer

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

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