Hi Even, Thanks for your help!
Yes, I've tried "set USE_PATH_FOR_GDAL_PYTHON=YES" but the behaviour does not change. I believe OSGeo4W shell sets the environment variables through .bat files, and does not use system path. Am I right, Jurgen? (sorry for calling in CC) Meanwhile I've found those issue and PR that seems related: https://github.com/OSGeo/gdal/issues/3898 https://github.com/OSGeo/gdal/pull/3923 Following the steps to reproduce the problem I get the error message: C:\Users\PedroVenancio\demo.py: from osgeo import gdal (arosics) PS C:\Users\PedroVenancio> gdalinfo --versionGDAL 3.3.2, released 2021/09/01 (arosics) PS C:\Users\PedroVenancio> set USE_PATH_FOR_GDAL_PYTHON=YES (arosics) PS C:\Users\PedroVenancio> python demo.py 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.During handling of the above exception, another exception occurred:Traceback (most recent call last): File "demo.py", line 1, in <module> from osgeo import gdal 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(). Are those ones really related? Thanks Even and Jurgen! Pedro Even Rouault <even.roua...@spatialys.com> escreveu no dia quarta, 13/10/2021 à(s) 11:43: > Pedro, > > Did you try to "set USE_PATH_FOR_GDAL_PYTHON=YES" environment variable a > suggested ? > > Can you check if it set in OSGeo4W shell ? ("echo > %USE_PATH_FOR_GDAL_PYTHON%") > > Wondering if we shouldn't enable that behavior automatically... although > that we would go against upstream Python policy > > Even > Le 13/10/2021 à 12:14, Pedro Venâncio a écrit : > > 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 > > > _______________________________________________ > gdal-dev mailing > listgdal-dev@lists.osgeo.orghttps://lists.osgeo.org/mailman/listinfo/gdal-dev > > -- http://www.spatialys.com > My software is free, but my time generally not. > >
_______________________________________________ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev