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)?

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Aug 1, 2018 at 2:36
1
  • @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! Commented Aug 1, 2018 at 18:16

1 Answer 1

2

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" 
answered Aug 2, 2018 at 13:36

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.