简体   繁体   中英

Installing GDAL with Anaconda

I just did a fresh install of Anaconda3 and am trying to add GDAL/OGR. I've tried installing with both conda install gdal and conda install -c conda-forge gdal . In both cases, the install completes successfully, but when I import gdal, it raises the error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\user\AppData\Local\Continuum\miniconda3\lib\site-packages\osgeo\__init__.py", line 25, in <module>
    _gdal = swig_import_helper()
  File "C:\Users\user\AppData\Local\Continuum\miniconda3\lib\site-packages\osgeo\__init__.py", line 21, in swig_import_helper
    _mod = imp.load_module('_gdal', fp, pathname, description)
  File "C:\Users\user\AppData\Local\Continuum\miniconda3\lib\imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "C:\Users\user\AppData\Local\Continuum\miniconda3\lib\imp.py", line 343, in load_dynamic
    return _load(spec)
ImportError: DLL load failed: The specified module could not be found.

I think it is related to this error https://github.com/conda-forge/gdal-feedstock/issues/219

You should use virtual environments, (at least in order to quickly test different configurations)

You can try one of the following fixes:

1)

From the issue it seems like a problem with vs2015_runtime which has to be 14 for it to work. So check your version of vc2015 runtime, if it is too high you can downgrade it by.

conda create --name gdal_vs15_14 python=3.6.5
(Here you can probably see what version of vs2015_runtime it installs into the environment)

conda activate gdal_vs15_14

conda install -c conda-forge vs2015_runtime=14

conda install -c conda-forge gdal

2)

Another simple fix for now, is by using python 2.7 (which is of course not optimal, but at least worked for me for now as a quick fix)

conda create --name gdal_py27 python=2.7

conda activate gdal_py27

conda install -c conda-forge gdal

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM