[gdal-dev] Running GDAL through Python >= 3.8 on Anaconda - DLL load failed

Pedro Venâncio pedrongvenancio at gmail.com
Wed Oct 13 03:14:00 PDT 2021


Hi all,

I'm trying to create an Anaconda environment to run arosics, a software
that performs automatic subpixel co-registration of two satellite image
datasets.

The environment seems correctly created, with GDAL working as expected on
the CLI:

(arosics) PS C:\Users\PedroVenancio> gdalinfo --versionGDAL 3.3.2,
released 2021/09/01


The problem is that when Python (versions >=3.8) calls GDAL, it gives an
error:

(arosics) PS C:\Users\PedroVenancio> pythonPython 3.8.12 | packaged by
conda-forge | (default, Oct 12 2021, 21:22:46) [MSC v.1916 64 bit
(AMD64)] on win32Type "help", "copyright", "credits" or "license" for
more information.>>> from osgeo import gdalTraceback (most recent call
last):  File "C:\Users\PedroVenancio\anaconda3\envs\arosics\lib\site-packages\osgeo\__init__.py",
line 21, in swig_import_helper    return
importlib.import_module(mname)  File
"C:\Users\PedroVenancio\anaconda3\envs\arosics\lib\importlib\__init__.py",
line 127, in import_module    return
_bootstrap._gcd_import(name[level:], package, level)  File "<frozen
importlib._bootstrap>", line 1014, in _gcd_import  File "<frozen
importlib._bootstrap>", line 991, in _find_and_load  File "<frozen
importlib._bootstrap>", line 975, in _find_and_load_unlocked  File
"<frozen importlib._bootstrap>", line 657, in _load_unlocked  File
"<frozen importlib._bootstrap>", line 556, in module_from_spec  File
"<frozen importlib._bootstrap_external>", line 1166, in create_module
File "<frozen importlib._bootstrap>", line 219, in
_call_with_frames_removedImportError: DLL load failed while importing
_gdal: Impossível localizar o procedimento especificado.During
handling of the above exception, another exception occurred:Traceback
(most recent call last):  File "<stdin>", line 1, in <module>  File
"C:\Users\PedroVenancio\anaconda3\envs\arosics\lib\site-packages\osgeo\__init__.py",
line 37, in <module>    _gdal = swig_import_helper()  File
"C:\Users\PedroVenancio\anaconda3\envs\arosics\lib\site-packages\osgeo\__init__.py",
line 33, in swig_import_helper    raise ImportError(traceback_string +
'\n' + msg)ImportError: Traceback (most recent call last):  File
"C:\Users\PedroVenancio\anaconda3\envs\arosics\lib\site-packages\osgeo\__init__.py",
line 21, in swig_import_helper    return
importlib.import_module(mname)  File
"C:\Users\PedroVenancio\anaconda3\envs\arosics\lib\importlib\__init__.py",
line 127, in import_module    return
_bootstrap._gcd_import(name[level:], package, level)  File "<frozen
importlib._bootstrap>", line 1014, in _gcd_import  File "<frozen
importlib._bootstrap>", line 991, in _find_and_load  File "<frozen
importlib._bootstrap>", line 975, in _find_and_load_unlocked  File
"<frozen importlib._bootstrap>", line 657, in _load_unlocked  File
"<frozen importlib._bootstrap>", line 556, in module_from_spec  File
"<frozen importlib._bootstrap_external>", line 1166, in create_module
File "<frozen importlib._bootstrap>", line 219, in
_call_with_frames_removedImportError: DLL load failed while importing
_gdal: Impossível localizar o procedimento especificado.On Windows,
with Python >= 3.8, DLLs are no longer imported from the PATH.If
gdalXXX.dll is in the PATH, then set the USE_PATH_FOR_GDAL_PYTHON=YES
environment variableto feed the PATH into os.add_dll_directory().

I've reported this error in the arosics issue tracker (
https://git.gfz-potsdam.de/danschef/arosics/-/issues/66), but it seems to
be working as expected in some similar systems (windows 10).

So I believe it can be some kind of conflict with other installations on my
machine. I've for instance OSGeo4W and everything works fine:

C:\OSGeo4W>gdalinfo --versionGDAL 3.3.1, released
2021/06/28C:\OSGeo4W>pythonPython 3.9.5 (tags/v3.9.5:0a7dcbd, May  3
2021, 17:27:52) [MSC v.1928 64 bit (AMD64)] on win32Type "help",
"copyright", "credits" or "license" for more information.>>> from
osgeo import gdal>>> gdal<module 'osgeo.gdal' from
'C:\\OSGeo4W\\apps\\Python39\\lib\\site-packages\\osgeo\\gdal.py'>


Has anyone seen this kind of error? Any hints to overcome?

Thank you very much!

Best regards,
Pedro
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20211013/8ad16d18/attachment.html>


More information about the gdal-dev mailing list