conda-forge / gdal-feedstock

A conda-smithy repository for gdal.
BSD 3-Clause "New" or "Revised" License
30 stars 62 forks source link

ImportError: DLL load failed while importing _gdal: The specified procedure could not be found. At Gdal 3.4.3 #883

Open julian-belina opened 7 months ago

julian-belina commented 7 months ago

Solution to issue cannot be found in the documentation.

Issue

When install gdal 3.4.3 in a new environment i get the following traceback when i try to load gdal:

C:\Users\PAVAN_F>conda activate test_gdal_env

(test_gdal_env) C:\Users\PAVAN_F>python Python 3.10.13 | packaged by conda-forge | (main, Dec 23 2023, 15:27:34) [MSC v.1937 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.

from osgeo import gdal Traceback (most recent call last): File "C:\Users\PAVAN_F\AppData\Local\Continuum\Anaconda3\envs\test_gdal_env\lib\site-packages\osgeo__init.py", line 29, in swig_import_helper return importlib.import_module(mname) File "C:\Users\PAVAN_F\AppData\Local\Continuum\Anaconda3\envs\test_gdal_env\lib\importlib\init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1050, in _gcd_import File "", line 1027, in _find_and_load File "", line 1006, in _find_and_load_unlocked File "", line 674, in _load_unlocked File "", line 571, in module_from_spec File "", line 1176, in create_module File "", line 241, in _call_with_frames_removed ImportError: DLL load failed while importing _gdal: The specified procedure could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "", line 1, in File "C:\Users\PAVAN_F\AppData\Local\Continuum\Anaconda3\envs\test_gdal_env\lib\site-packages\osgeo__init.py", line 45, in _gdal = swig_import_helper() File "C:\Users\PAVAN_F\AppData\Local\Continuum\Anaconda3\envs\test_gdal_env\lib\site-packages\osgeo__init__.py", line 42, in swig_import_helper return importlib.import_module('_gdal') File "C:\Users\PAVAN_F\AppData\Local\Continuum\Anaconda3\envs\test_gdal_env\lib\importlib\init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) ModuleNotFoundError: No module named '_gdal'

Installed packages

# packages in environment at C:\Users\PAVAN_F\AppData\Local\Continuum\Anaconda3\envs\test_gdal_env:
#
# Name                    Version                   Build  Channel
blosc                     1.21.5               hdccc3a2_0    conda-forge
boost-cpp                 1.78.0               h9f4b32c_4    conda-forge
bzip2                     1.0.8                hcfcfb64_5    conda-forge
ca-certificates           2023.11.17           h56e8100_0    conda-forge
cairo                     1.16.0            hd694305_1014    conda-forge
cfitsio                   4.1.0                h5a969a9_0    conda-forge
curl                      8.5.0                hd5e4a3a_0    conda-forge
expat                     2.5.0                h63175ca_1    conda-forge
font-ttf-dejavu-sans-mono 2.37                 hab24e00_0    conda-forge
font-ttf-inconsolata      3.000                h77eed37_0    conda-forge
font-ttf-source-code-pro  2.038                h77eed37_0    conda-forge
font-ttf-ubuntu           0.83                 h77eed37_1    conda-forge
fontconfig                2.14.2               hbde0cde_0    conda-forge
fonts-conda-ecosystem     1                             0    conda-forge
fonts-conda-forge         1                             0    conda-forge
freetype                  2.12.1               hdaf720e_2    conda-forge
freexl                    1.0.6                h67ca5e6_1    conda-forge
gdal                      3.4.3           py310h644bc08_1    conda-forge
geos                      3.11.1               h1537add_0    conda-forge
geotiff                   1.7.1                h4ffd875_4    conda-forge
gettext                   0.21.1               h5728263_0    conda-forge
hdf4                      4.2.15               h1b1b6ef_5    conda-forge
hdf5                      1.12.2          nompi_h57737ce_101    conda-forge
icu                       70.1                 h0e60522_0    conda-forge
intel-openmp              2023.2.0         h57928b3_50497    conda-forge
jpeg                      9e                   hcfcfb64_3    conda-forge
kealib                    1.5.0                h61be68b_0    conda-forge
krb5                      1.21.2               heb0366b_0    conda-forge
lcms2                     2.14                 h90d422f_0    conda-forge
lerc                      4.0.0                h63175ca_0    conda-forge
libaec                    1.1.2                h63175ca_1    conda-forge
libblas                   3.9.0              20_win64_mkl    conda-forge
libcblas                  3.9.0              20_win64_mkl    conda-forge
libcurl                   8.5.0                hd5e4a3a_0    conda-forge
libdeflate                1.14                 hcfcfb64_0    conda-forge
libexpat                  2.5.0                h63175ca_1    conda-forge
libffi                    3.4.2                h8ffe710_5    conda-forge
libgdal                   3.4.3                h43f05fc_1    conda-forge
libglib                   2.78.1               he8f3873_0    conda-forge
libhwloc                  2.9.3           default_haede6df_1009    conda-forge
libiconv                  1.17                 hcfcfb64_2    conda-forge
libkml                    1.3.0             hd45a9bc_1016    conda-forge
liblapack                 3.9.0              20_win64_mkl    conda-forge
libnetcdf                 4.8.1           nompi_h8c042bf_106    conda-forge
libpng                    1.6.39               h19919ed_0    conda-forge
libpq                     15.4                 h1beaf6b_5    conda-forge
librttopo                 1.1.0               he22b5cd_12    conda-forge
libspatialite             5.0.1               h07bf483_22    conda-forge
libsqlite                 3.44.2               hcfcfb64_0    conda-forge
libssh2                   1.11.0               h7dfc565_0    conda-forge
libtiff                   4.4.0                hc4f729c_5    conda-forge
libwebp-base              1.3.2                hcfcfb64_0    conda-forge
libxml2                   2.12.4               hc3477c8_1    conda-forge
libzip                    1.10.1               h1d365fa_3    conda-forge
libzlib                   1.2.13               hcfcfb64_5    conda-forge
lz4-c                     1.9.4                hcfcfb64_0    conda-forge
mkl                       2023.2.0         h6a75c08_50497    conda-forge
numpy                     1.26.3          py310hf667824_0    conda-forge
openjpeg                  2.5.0                hc9384bd_1    conda-forge
openssl                   3.2.0                hcfcfb64_1    conda-forge
pcre2                     10.40                h17e33f8_0    conda-forge
pip                       23.3.2             pyhd8ed1ab_0    conda-forge
pixman                    0.43.0               h63175ca_0    conda-forge
poppler                   22.12.0              ha6c1112_0    conda-forge
poppler-data              0.4.12               hd8ed1ab_0    conda-forge
postgresql                15.4                 h1beaf6b_5    conda-forge
proj                      9.1.0                h3863b3b_0    conda-forge
pthreads-win32            2.9.1                hfa6e2cd_3    conda-forge
python                    3.10.13         h4de0772_1_cpython    conda-forge
python_abi                3.10                    4_cp310    conda-forge
setuptools                69.0.3             pyhd8ed1ab_0    conda-forge
snappy                    1.1.10               hfb803bf_0    conda-forge
sqlite                    3.44.2               hcfcfb64_0    conda-forge
tbb                       2021.11.0            h91493d7_0    conda-forge
tiledb                    2.13.2               h3132609_0    conda-forge
tk                        8.6.13               h5226925_1    conda-forge
tzdata                    2023d                h0c530f3_0    conda-forge
ucrt                      10.0.22621.0         h57928b3_0    conda-forge
uriparser                 0.9.7                h1537add_1    conda-forge
vc                        14.3                hcf57466_18    conda-forge
vc14_runtime              14.38.33130         h82b7239_18    conda-forge
vs2015_runtime            14.38.33130         hcb4865c_18    conda-forge
wheel                     0.42.0             pyhd8ed1ab_0    conda-forge
xerces-c                  3.2.5                h63175ca_0    conda-forge
xz                        5.2.6                h8d14728_0    conda-forge
zlib                      1.2.13               hcfcfb64_5    conda-forge
zstd                      1.5.5                h12be248_0    conda-forge

Environment info

active environment : test_gdal_env
    active env location : C:\Users\PAVAN_F\AppData\Local\Continuum\Anaconda3\envs\test_gdal_env
            shell level : 1
       user config file : C:\Users\PAVAN_F\.condarc
populated config files : C:\Users\PAVAN_F\.condarc
          conda version : 23.9.0
    conda-build version : 3.28.3
         python version : 3.9.7.final.0
       virtual packages : __archspec=1=x86_64
                          __win=0=0
       base environment : C:\Users\PAVAN_F\AppData\Local\Continuum\Anaconda3  (writable)
      conda av data dir : C:\Users\PAVAN_F\AppData\Local\Continuum\Anaconda3\etc\conda
  conda av metadata url : None
           channel URLs :
https://repo.anaconda.com/pkgs/main/win-64

https://repo.anaconda.com/pkgs/main/noarch

https://repo.anaconda.com/pkgs/r/win-64

https://repo.anaconda.com/pkgs/r/noarch

https://repo.anaconda.com/pkgs/msys2/win-64

https://repo.anaconda.com/pkgs/msys2/noarch
          package cache : C:\Users\PAVAN_F\AppData\Local\Continuum\Anaconda3\pkgs
                          C:\Users\PAVAN_F\.conda\pkgs
                          C:\Users\PAVAN_F\AppData\Local\conda\conda\pkgs
       envs directories : C:\Users\PAVAN_F\AppData\Local\Continuum\Anaconda3\envs
                          C:\Users\PAVAN_F\.conda\envs
                          C:\Users\PAVAN_F\AppData\Local\conda\conda\envs
               platform : win-64
             user-agent : conda/23.9.0 requests/2.31.0 CPython/3.9.7 Windows/10 Windows/10.0.19045 solver/libmamba conda-libmamba-solver/23.9.3 libmambapy/1.5.1 aau/0.4.3 c/4LNyGqzXy0VsBc52RAUfOQ s/_kPw7OgJloq2HMRgY6UQFg e/HsV7qpk-64Bb1qaG4SeWsA
          administrator : False
             netrc file : None
           offline mode : False
akrherz commented 7 months ago

GDAL 3.4.3 is ancient, is that version a requirement for your needs?

julian-belina commented 7 months ago

I suspect that that the Visual Studio might be a problem. This problem occurs on a Windows 10 machine with the Microsoft Visual C++ 2015-2019 Redistributable (x64) -14.28.29914.0

On a windows 11 machine with Microsoft Visual C++ 2015-2022 Redistributable (x64) -14.36.32532 The same packages are installed and no error occurs

julian-belina commented 7 months ago

chine with Microsoft Vi

Unfortunately yes. A lot of software at my institute is bound to it.

julian-belina commented 7 months ago

@akrherz Updating the Microsoft Visual C++ 2015-2019 Redistributable from 14.28.29914 to 14.34.33130 resolved the problem. Is it possible to update the meta data to respect this constraint?

DOptimusPrime commented 7 months ago

I am also running into the same problem. I have Microsoft Visual C++ 2012 11.0.61030.0, Redistributable, Microsoft Visual C++ 2015-2019 Redistributable, Microsoft Visual C++ 2015-2022 Redistributable. I am have gdal 0.3.0. This is the one I need to run code. Any ideas

julian-belina commented 7 months ago

@DOptimusPrime Is it possible that you mean a diffrent gdal version than 0.3.0? This version would be very old and is not on conda-forge. At least gdal 3.4.x versions depend on the Microsoft Visual C++ 2015-2022 redistributable. An update of the redistributable could resolve the error.

A possible cause for the error is that the binaries provided by conda-forge have been created with a newer version of Visual C++. The newer versions of the redistributable are backwards compatible as you can read here