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

Even Rouault even.rouault at spatialys.com
Wed Oct 13 06:29:39 PDT 2021


Can you change in __init__.py

                 try:
                     os.add_dll_directory(p)
                 except FileNotFoundError:
                     continue


to

                 try:
                     os.add_dll_directory(p)
                 except (FileNotFoundError, OSError):
                     continue

Le 13/10/2021 à 15:20, Pedro Venâncio a écrit :
>
>     But I don't understand why you still get the "On Windows, with
>     Python >= 3.8, DLLs are no longer imported from the PATH." error
>     message.
>
>     It shouldn't be emitted because USE_PATH_FOR_GDAL_PYTHON is set:
>     https://github.com/OSGeo/gdal/blob/f3a83a2c2628219bdc60001580da677758015a60/gdal/swig/python/osgeo/__init__.py#L25
>     <https://github.com/OSGeo/gdal/blob/f3a83a2c2628219bdc60001580da677758015a60/gdal/swig/python/osgeo/__init__.py#L25>
>
>     Something weird happening here. Perhaps edit
>     https://github.com/OSGeo/gdal/blob/f3a83a2c2628219bdc60001580da677758015a60/gdal/swig/python/osgeo/__init__.py#L25
>     <https://github.com/OSGeo/gdal/blob/f3a83a2c2628219bdc60001580da677758015a60/gdal/swig/python/osgeo/__init__.py#L25>
>     to display os.environ
>
>
> Even, I was not setting the environment variable correctly on conda. 
> It needs to be
>
> |conda env config vars set USE_PATH_FOR_GDAL_PYTHON=YES|
>
> and then I already get
> conda env config vars list
> USE_PATH_FOR_GDAL_PYTHON = YES
> So, the error message had changed
> python demo.py
> 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 11, in <module>
> os.add_dll_directory(p)
> File "C:\Users\PedroVenancio\anaconda3\envs\arosics\lib\os.py", line 
> 1109, in add_dll_directory
> cookie = nt._add_dll_directory(path)
> OSError: [WinError 87] O parâmetro está incorreto: '.'
>
-- 
http://www.spatialys.com
My software is free, but my time generally not.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20211013/60bd7a9a/attachment.html>


More information about the gdal-dev mailing list