Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: DLL load failed while importing _version: The specified procedure could not be found. #250

Open
1 task done
Vaspra opened this issue Jul 26, 2022 · 21 comments
Labels

Comments

@Vaspra
Copy link

Vaspra commented Jul 26, 2022

Solution to issue cannot be found in the documentation.

  • I checked the documentation.

Issue

Error as above, stack:

(photo_grid) C:\WINDOWS\system32>python -m grid
~~~~~~~~~*~~~~~~~~~*~~~~~~~~~*~~~~~~~~~*~~~~~~~~~*~~~~~~~~~
                 Welcome to GRID Ver.1.2.18
~~~~~~~~~*~~~~~~~~~*~~~~~~~~~*~~~~~~~~~*~~~~~~~~~*~~~~~~~~~
Author      : James Chen <chun-peng.chen@wsu.edu>
Last update : Aug 31, 2021
User manual : https://poissonfish.github.io/GRID/
~~~~~~~~~*~~~~~~~~~*~~~~~~~~~*~~~~~~~~~*~~~~~~~~~*~~~~~~~~~
Recent update
    - Support images with huge dimensions (> 32767)
    - Add CRS to shapefiles (.prj)
    - Support ESRI shapefile compatible in QGIS
~~~~~~~~~*~~~~~~~~~*~~~~~~~~~*~~~~~~~~~*~~~~~~~~~*~~~~~~~~~
Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\envs\photo_grid\lib\runpy.py", line 185, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "C:\ProgramData\Anaconda3\envs\photo_grid\lib\runpy.py", line 144, in _get_module_details
    return _get_module_details(pkg_main_name, error)
  File "C:\ProgramData\Anaconda3\envs\photo_grid\lib\runpy.py", line 111, in _get_module_details
    __import__(pkg_name)
  File "C:\ProgramData\Anaconda3\envs\photo_grid\lib\site-packages\grid\__init__.py", line 72, in <module>
    from .grid import *
  File "C:\ProgramData\Anaconda3\envs\photo_grid\lib\site-packages\grid\grid.py", line 4, in <module>
    from .gmap import *
  File "C:\ProgramData\Anaconda3\envs\photo_grid\lib\site-packages\grid\gmap.py", line 7, in <module>
    from .io import *
  File "C:\ProgramData\Anaconda3\envs\photo_grid\lib\site-packages\grid\io.py", line 12, in <module>
    import rasterio
  File "C:\ProgramData\Anaconda3\envs\photo_grid\lib\site-packages\rasterio\__init__.py", line 13, in <module>
    from rasterio._version import gdal_version, get_geos_version, get_proj_version
ImportError: DLL load failed while importing _version: The specified procedure could not be found.

Seems to be running into trouble with ._version. Local filename of this in sitepackages is _version.cp38-win_amd64.pyd.
I have tried multiple versions of python, all with fresh installs and environments. Any help would be appreciated.

All instruction steps followed for install.

Installed packages

(photo_grid) C:\WINDOWS\system32>conda list
# packages in environment at C:\ProgramData\Anaconda3\envs\photo_grid:
#
# Name                    Version                   Build  Channel
affine                    2.3.1              pyhd8ed1ab_0    conda-forge
asgiref                   3.5.2                    pypi_0    pypi
attrs                     21.4.0             pyhd8ed1ab_0    conda-forge
backports-zoneinfo        0.2.1                    pypi_0    pypi
blosc                     1.21.1               h74325e0_3    conda-forge
boost-cpp                 1.74.0               h9f4b32c_8    conda-forge
bzip2                     1.0.8                h8ffe710_4    conda-forge
ca-certificates           2022.6.15            h5b45459_0    conda-forge
cairo                     1.16.0            h0ac17fb_1011    conda-forge
certifi                   2022.6.15        py38haa244fe_0    conda-forge
cfitsio                   4.1.0                h5a969a9_0    conda-forge
click                     8.1.3            py38haa244fe_0    conda-forge
click-plugins             1.1.1                      py_0    conda-forge
cligj                     0.7.2              pyhd8ed1ab_1    conda-forge
colorama                  0.4.5              pyhd8ed1ab_0    conda-forge
curl                      7.83.1               h789b8ee_0    conda-forge
cycler                    0.11.0                   pypi_0    pypi
django                    4.0.6                    pypi_0    pypi
expat                     2.4.8                h39d44d4_0    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                 hab24e00_0    conda-forge
fontconfig                2.14.0               hce3cb01_0    conda-forge
fonts-conda-ecosystem     1                             0    conda-forge
fonts-conda-forge         1                             0    conda-forge
fonttools                 4.34.4                   pypi_0    pypi
freetype                  2.10.4               h546665d_1    conda-forge
freexl                    1.0.6                ha8e266a_0    conda-forge
geos                      3.11.0               h39d44d4_0    conda-forge
geotiff                   1.7.1                h714bc5f_3    conda-forge
gettext                   0.19.8.1          ha2e2712_1008    conda-forge
h5py                      3.7.0                    pypi_0    pypi
hdf4                      4.2.15               h0e5069d_3    conda-forge
hdf5                      1.12.1          nompi_h57737ce_104    conda-forge
icu                       70.1                 h0e60522_0    conda-forge
image                     1.5.33                   pypi_0    pypi
intel-openmp              2022.1.0          h57928b3_3787    conda-forge
joblib                    1.1.0                    pypi_0    pypi
jpeg                      9e                   h8ffe710_2    conda-forge
kealib                    1.4.15               h8995ca9_0    conda-forge
kiwisolver                1.4.4                    pypi_0    pypi
krb5                      1.19.3               hc8ab02b_0    conda-forge
lcms2                     2.12                 h2a16943_0    conda-forge
lerc                      3.0                  h0e60522_0    conda-forge
libblas                   3.9.0              15_win64_mkl    conda-forge
libcblas                  3.9.0              15_win64_mkl    conda-forge
libcurl                   7.83.1               h789b8ee_0    conda-forge
libdeflate                1.12                 h8ffe710_0    conda-forge
libffi                    3.4.2                h8ffe710_5    conda-forge
libgdal                   3.5.1                h9e25771_1    conda-forge
libglib                   2.72.1               h3be07f2_0    conda-forge
libiconv                  1.16                 he774522_0    conda-forge
libkml                    1.3.0             h9859afa_1014    conda-forge
liblapack                 3.9.0              15_win64_mkl    conda-forge
libnetcdf                 4.8.1           nompi_h1cc8e9d_102    conda-forge
libpng                    1.6.37               h1d00b33_3    conda-forge
libpq                     14.4                 h1ea2d34_0    conda-forge
librttopo                 1.1.0               h2842628_11    conda-forge
libspatialite             5.0.1               ha17912d_18    conda-forge
libssh2                   1.10.0               h9a1e1f7_2    conda-forge
libtiff                   4.4.0                h2ed3b44_1    conda-forge
libwebp-base              1.2.3                h8ffe710_2    conda-forge
libxml2                   2.9.14               hf5bbc77_3    conda-forge
libzip                    1.9.2                h519de47_0    conda-forge
libzlib                   1.2.12               h8ffe710_2    conda-forge
lz4-c                     1.9.3                h8ffe710_1    conda-forge
matplotlib                3.5.2                    pypi_0    pypi
mkl                       2022.1.0           h6a75c08_874    conda-forge
numpy                     1.23.1           py38h223ccf5_0    conda-forge
opencv-python             4.6.0.66                 pypi_0    pypi
openjpeg                  2.4.0                hb211442_1    conda-forge
openssl                   3.0.5                h8ffe710_0    conda-forge
packaging                 21.3                     pypi_0    pypi
pandas                    1.4.3                    pypi_0    pypi
pcre                      8.45                 h0e60522_0    conda-forge
photo-grid                1.2.18                   pypi_0    pypi
pillow                    9.2.0                    pypi_0    pypi
pip                       22.2               pyhd8ed1ab_0    conda-forge
pixman                    0.40.0               h8ffe710_0    conda-forge
poppler                   22.04.0              h24fffdf_1    conda-forge
poppler-data              0.4.11               hd8ed1ab_0    conda-forge
postgresql                14.4                 he353ca9_0    conda-forge
proj                      9.0.1                h1cfcee9_1    conda-forge
pyparsing                 3.0.9              pyhd8ed1ab_0    conda-forge
pyqt5                     5.15.7                   pypi_0    pypi
pyqt5-qt5                 5.15.2                   pypi_0    pypi
pyqt5-sip                 12.11.0                  pypi_0    pypi
pyshp                     2.3.0                    pypi_0    pypi
python                    3.8.13          hcf16a7b_0_cpython    conda-forge
python-dateutil           2.8.2                    pypi_0    pypi
python_abi                3.8                      2_cp38    conda-forge
pytz                      2022.1                   pypi_0    pypi
qdarkstyle                3.1                      pypi_0    pypi
qtpy                      2.1.0                    pypi_0    pypi
rasterio                  1.3.0            py38h8b19869_0    conda-forge
scikit-learn              1.1.1                    pypi_0    pypi
scipy                     1.8.1                    pypi_0    pypi
setuptools                63.2.0           py38haa244fe_0    conda-forge
six                       1.16.0                   pypi_0    pypi
sklearn                   0.0                      pypi_0    pypi
snappy                    1.1.9                h82413e6_1    conda-forge
snuggs                    1.4.7                      py_0    conda-forge
sqlite                    3.39.2               h8ffe710_0    conda-forge
sqlparse                  0.4.2                    pypi_0    pypi
tbb                       2021.5.0             h2d74725_1    conda-forge
threadpoolctl             3.1.0                    pypi_0    pypi
tiledb                    2.9.5                h3132609_0    conda-forge
tk                        8.6.12               h8ffe710_0    conda-forge
tqdm                      4.64.0                   pypi_0    pypi
tzdata                    2022.1                   pypi_0    pypi
ucrt                      10.0.20348.0         h57928b3_0    conda-forge
vc                        14.2                 hb210afc_6    conda-forge
vs2015_runtime            14.29.30037          h902a5da_6    conda-forge
wheel                     0.37.1             pyhd8ed1ab_0    conda-forge
xerces-c                  3.2.3                h0e60522_5    conda-forge
xz                        5.2.5                h62dcd97_1    conda-forge
zlib                      1.2.12               h8ffe710_2    conda-forge
zstd                      1.5.2                h6255e5f_2    conda-forge

Environment info

(photo_grid) C:\WINDOWS\system32>conda info

     active environment : photo_grid
    active env location : C:\ProgramData\Anaconda3\envs\photo_grid
            shell level : 4
       user config file : C:\Users\dougl\.condarc
 populated config files : C:\Users\dougl\.condarc
          conda version : 4.9.2
    conda-build version : 3.18.11
         python version : 3.7.0.final.0
       virtual packages : __cuda=11.7=0
                          __win=0=0
                          __archspec=1=x86_64
       base environment : C:\ProgramData\Anaconda3  (writable)
           channel URLs : https://conda.anaconda.org/conda-forge/win-64
                          https://conda.anaconda.org/conda-forge/noarch
                          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:\ProgramData\Anaconda3\pkgs
                          C:\Users\dougl\.conda\pkgs
                          C:\Users\dougl\AppData\Local\conda\conda\pkgs
       envs directories : C:\ProgramData\Anaconda3\envs
                          C:\Users\dougl\.conda\envs
                          C:\Users\dougl\AppData\Local\conda\conda\envs
               platform : win-64
             user-agent : conda/4.9.2 requests/2.25.1 CPython/3.7.0 Windows/10 Windows/10.0.19041
          administrator : True
             netrc file : None
           offline mode : False
@Vaspra Vaspra added the bug label Jul 26, 2022
@xylar
Copy link
Contributor

xylar commented Jul 26, 2022

Hi @Vaspra, it looks from your conda list like you have a mix of packages from conda-forge and pypi. This generally doesn't work out well and leads to the kinds of DLL problems that you're reporting. Could you try creating a new environment that just uses conda-forge and see if that works out for you?
See: https://conda-forge.org/#about

conda config --add channels conda-forge
conda config --set channel_priority strict
conda create -y -n rasterio_test python=3.8 rasterio ...

In the last command, list as many packages as you need to.
Then, do:

conda activate rasterio_test

There may be some Windows nuances that I don't know about. I'm a Linux user myself.

@Vaspra
Copy link
Author

Vaspra commented Jul 26, 2022

Hi @xylar, thanks for the quick reply.

I have created an environment entirely from conda-forge and validated that all conda list items are properly sourced (not from pypi).

The application I am attempting to use (https://poissonfish.github.io/GRID/ch1_started/installation.html#step-3-install-grid-via-pypi) has instructions to install rasterio using conda-forge but then instructs to install the application itself through pip/pypi. I have tried to tell pip to install packages through the conda-forge index url, but packages wind up not being found as I guess they're only hosted on pypi.

I'm assuming the required rasterio files are only on conda-forge, so am I left in a situation where I cannot obtain 100% of packages required for both rasterio and this application from one source, unless I am mistaken.

@xylar
Copy link
Contributor

xylar commented Jul 27, 2022

@Vaspra, thanks for the clarification. It sounds like your issue isn't caused by mixing channels as I suspected. It seems like it might be the same as #240, which I'm sorry to say that I don't have the expertise to help with. I do hope someone with expertise in windows and a windows machine can help!

@xindyhu
Copy link

xindyhu commented Oct 18, 2022

Hi @Vaspra , I ran into a similar issue when installing rasterio. I followed tips here:
https://stackoverflow.com/questions/57518050/conda-install-and-update-do-not-work-also-solving-environment-get-errors
You create an env and activate that, then do the installation within the env, it worked for me on my windows machine.

I recommend the package maintainer update the README to include this tip.

@snowman2
Copy link
Member

snowman2 commented Dec 9, 2022

I recently ran into this issue as well: https://github.com/corteva/rioxarray/actions/runs/3652596990/jobs/6171179962.

The strange thing is that it was working fine 10 days ago and there hasn't been any rasterio release since then. 🤔

@GGDRriedel
Copy link

I have this issue as well, it worked fine a month ago, I updated a different GDAL installation through OSGEO4W thogh(QGIS stuff)

@DevAlvaroF
Copy link

Can confirm that the issue is going on today. I installed it on a functional and existing env, seems to be working on a completely empty env so I'm guessing there's a conflict somewhere

@GGDRriedel
Copy link

I needed to solve this by downgrading in a completely new Conda env which is really suboptimal

@wkitlasten
Copy link

I got this error after updating pandas and accepteing all changes suggested by the pandas update.

I fixed it with: conda install rasterio=1.2.10 which made the following changes:

  Package          Version  Build                Channel                  Size
--------------------------------------------------------------------------------
  Install:
--------------------------------------------------------------------------------

  + pcre              8.45  h0e60522_0           conda-forge/win-64     Cached

  Change:
--------------------------------------------------------------------------------

  - fiona           1.8.22  py39hb5a1417_5       conda-forge
  + fiona           1.8.22  py39h9e0966e_0       conda-forge/win-64     Cached
  - geotiff          1.7.1  h720ab47_5           conda-forge
  + geotiff          1.7.1  h714bc5f_3           conda-forge/win-64     Cached
  - lcms2             2.14  ha5c8aab_1           conda-forge
  + lcms2             2.14  h90d422f_0           conda-forge/win-64        1MB
  - librttopo        1.1.0  he22b5cd_12          conda-forge
  + librttopo        1.1.0  h2842628_11          conda-forge/win-64     Cached
  - libspatialite    5.0.1  h07bf483_22          conda-forge
  + libspatialite    5.0.1  hd9530bf_19          conda-forge/win-64       12MB
  - openjpeg         2.5.0  ha2aaf27_2           conda-forge
  + openjpeg         2.5.0  hc9384bd_1           conda-forge/win-64     Cached
  - shapely          1.8.5  py39h7c5f289_2       conda-forge
  + shapely          1.8.5  py39h6f18ba6_1       conda-forge/win-64      426kB

  Downgrade:
--------------------------------------------------------------------------------

  - cfitsio          4.2.0  h9ebe7e4_0           conda-forge
  + cfitsio          4.1.0  h5a969a9_0           conda-forge/win-64     Cached
  - ffmpeg           5.1.2  gpl_h5b1d025_105     conda-forge
  + ffmpeg           4.4.2  gpl_h5b1d025_112     conda-forge/win-64       11MB
  - gdal             3.6.2  py39h3be0312_3       conda-forge
  + gdal             3.5.2  py39h3be0312_4       conda-forge/win-64     Cached
  - geos            3.11.1  h1537add_0           conda-forge
  + geos            3.11.0  h39d44d4_0           conda-forge/win-64     Cached
  - kealib           1.5.0  h61be68b_0           conda-forge
  + kealib          1.4.15  hdf81f3a_1           conda-forge/win-64     Cached
  - libdeflate        1.17  hcfcfb64_0           conda-forge
  + libdeflate        1.14  hcfcfb64_0           conda-forge/win-64     Cached
  - libgdal          3.6.2  h060c9ed_3           conda-forge
  + libgdal          3.5.2  h2477998_4           conda-forge/win-64     Cached
  - libpq             15.1  ha9684e8_3           conda-forge
  + libpq             14.5  ha9684e8_5           conda-forge/win-64        3MB
  - libtiff          4.5.0  hf8721a0_2           conda-forge
  + libtiff          4.4.0  hc4f729c_5           conda-forge/win-64      806kB
  - pillow           9.4.0  py39h9767c21_0       conda-forge
  + pillow           9.2.0  py39h595c93f_3       conda-forge/win-64       48MB
  - poppler        22.12.0  h183ae7b_1           conda-forge
  + poppler        22.10.0  ha6c1112_0           conda-forge/win-64     Cached
  - postgresql        15.1  hd87cd2b_3           conda-forge
  + postgresql        14.5  hd87cd2b_5           conda-forge/win-64       17MB
  - proj             9.1.0  heca977f_1           conda-forge
  + proj             9.0.1  h1cfcee9_1           conda-forge/win-64     Cached
  - pygeos            0.14  py39h7c5f289_0       conda-forge
  + pygeos            0.13  py39h6f18ba6_1       conda-forge/win-64      432kB
  - pyproj           3.4.1  py39h9727d73_0       conda-forge
  + pyproj           3.4.0  py39h2de216b_0       conda-forge/win-64     Cached
  - rasterio         1.3.4  py39hce277b7_0       conda-forge
  + rasterio        1.2.10  py39h223f425_7       conda-forge/win-64        8MB
  - tiledb          2.13.2  h3132609_0           conda-forge
  + tiledb          2.11.3  h3132609_1           conda-forge/win-64        3MB
  - vtk              9.2.5  qt_py39h52d64c9_201  conda-forge
  + vtk              9.2.2  qt_py39hca7f291_200  conda-forge/win-64     Cached

Now it works.

@DevAlvaroF
Copy link

After doing my research I found a way to make GDAL and Rasterio work on Jupyter Notebooks to avoid the "dll load failed while importing"

  1. Create New Environment called "EO" with
    conda create --name EO -c conda-forge python=3.9.7 gdal=3.3.2 rasterio=1.2.10 ipykernel=6.4.1 jupyter=1.0.0

  2. At this point you can import gdal from a normal ".py" file but not from a ".ipynb" (Jupyter Notebook)

from osgeo import gdal # Import gdal before rasterio
import rasterio

Example:

(base) C:\Users\xxx>conda activate EO

(EO) C:\Users\xxx>python
Python 3.9.7 | packaged by conda-forge | (default, Sep 29 2021, 19:15:42) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from osgeo import gdal
>>> import rasterio
>>> exit()
  1. Activate the newly created environment from the Anaconda command prompt
    conda activate EO

  2. Create a new kernel called "gdal"
    python -m ipykernel install --user --name=gdal

Example:

(EO) C:\Users\xxx>python -m ipykernel install --user --name=gdal
Installed kernelspec gdal in C:\Users\xxx\AppData\Roaming\jupyter\kernels\gdal
  1. Change the kernel in Jupyter Notebooks / PyCharm / Vs Code
    image

EXTRA NOTES

  • When trying to replicate the error after running this process for the first time I couldn't do it. Everything worked on jupyter notebooks after Step 3 with the "Python 3 ipykernel". Doing this may have changed something but I'm not certain what happened. I tried deleting the env but everything worked now.

  • The latest GDAL in Anaconda seems to install Python 3.10 which is one of the biggest issues (that's why I had to find working versions)

@DevAlvaroF
Copy link

Solution #2

After installing 1 by 1 I figured out that GDAL version gets changed with Basemap, which messes up the packages and the dll error starts to appear.

I instead installed CartoPy and Everything Seems fine. Following is the lines I use to install and the dependencies:

Installation commands

conda create --name EO -c conda-forge python=3.9
conda install -c conda-forge sentinelsat rasterio
conda install -c conda-forge geopandas pyproj fiona
conda install -c conda-forge numpy matplotlib scipy scikit-learn netcdf4 xarray cartopy natsort
conda install -c conda-forge ipywidgets

Dependencies:

dependencies:
  - affine=2.4.0
  - appdirs=1.4.4
  - attrs=22.2.0
  - blosc=1.21.3
  - boost-cpp=1.78.0
  - branca=0.6.0
  - brotli=1.0.9
  - brotli-bin=1.0.9
  - brotlipy=0.7.0
  - bzip2=1.0.8
  - ca-certificates=2022.12.7
  - cairo=1.16.0
  - cartopy=0.21.1
  - certifi=2022.12.7
  - cffi=1.15.1
  - cfitsio=4.2.0
  - cftime=1.6.2
  - charset-normalizer=2.1.1
  - click=8.1.3
  - click-plugins=1.1.1
  - cligj=0.7.2
  - colorama=0.4.6
  - contourpy=1.0.7
  - cryptography=39.0.0
  - curl=7.87.0
  - cycler=0.11.0
  - expat=2.5.0
  - fiona=1.8.22
  - folium=0.14.0
  - font-ttf-dejavu-sans-mono=2.37
  - font-ttf-inconsolata=3.000
  - font-ttf-source-code-pro=2.038
  - font-ttf-ubuntu=0.83
  - fontconfig=2.14.1
  - fonts-conda-ecosystem=1
  - fonts-conda-forge=1
  - fonttools=4.38.0
  - freetype=2.12.1
  - freexl=1.0.6
  - gdal=3.6.2
  - geojson=2.5.0
  - geomet=1.0.0
  - geopandas=0.12.2
  - geopandas-base=0.12.2
  - geos=3.11.1
  - geotiff=1.7.1
  - gettext=0.21.1
  - glib=2.74.1
  - glib-tools=2.74.1
  - gst-plugins-base=1.21.3
  - gstreamer=1.21.3
  - hdf4=4.2.15
  - hdf5=1.12.2
  - html2text=2020.1.16
  - icu=70.1
  - idna=3.4
  - intel-openmp=2023.0.0
  - jinja2=3.1.2
  - joblib=1.2.0
  - jpeg=9e
  - kealib=1.5.0
  - kiwisolver=1.4.4
  - krb5=1.20.1
  - lcms2=2.14
  - lerc=4.0.0
  - libaec=1.0.6
  - libblas=3.9.0
  - libbrotlicommon=1.0.9
  - libbrotlidec=1.0.9
  - libbrotlienc=1.0.9
  - libcblas=3.9.0
  - libclang=15.0.7
  - libclang13=15.0.7
  - libcurl=7.87.0
  - libdeflate=1.17
  - libffi=3.4.2
  - libgdal=3.6.2
  - libglib=2.74.1
  - libhwloc=2.8.0
  - libiconv=1.17
  - libjpeg-turbo=2.1.4
  - libkml=1.3.0
  - liblapack=3.9.0
  - libnetcdf=4.8.1
  - libogg=1.3.4
  - libpng=1.6.39
  - libpq=15.1
  - librttopo=1.1.0
  - libspatialindex=1.9.3
  - libspatialite=5.0.1
  - libsqlite=3.40.0
  - libssh2=1.10.0
  - libtiff=4.5.0
  - libvorbis=1.3.7
  - libwebp-base=1.2.4
  - libxcb=1.13
  - libxml2=2.10.3
  - libzip=1.9.2
  - libzlib=1.2.13
  - lz4-c=1.9.3
  - m2w64-gcc-libgfortran=5.3.0
  - m2w64-gcc-libs=5.3.0
  - m2w64-gcc-libs-core=5.3.0
  - m2w64-gmp=6.1.0
  - m2w64-libwinpthread-git=5.0.0.4634.697f757
  - mapclassify=2.5.0
  - markupsafe=2.1.2
  - matplotlib=3.6.3
  - matplotlib-base=3.6.3
  - mkl=2022.1.0
  - msys2-conda-epoch=20160418
  - munch=2.5.0
  - munkres=1.1.4
  - netcdf4=1.6.2
  - networkx=3.0
  - numpy=1.24.1
  - openjpeg=2.5.0
  - openssl=3.0.7
  - packaging=23.0
  - pandas=1.5.3
  - pcre2=10.40
  - pillow=9.4.0
  - pip=22.3.1
  - pixman=0.40.0
  - ply=3.11
  - pooch=1.6.0
  - poppler=22.12.0
  - poppler-data=0.4.11
  - postgresql=15.1
  - proj=9.1.0
  - pthread-stubs=0.4
  - pthreads-win32=2.9.1
  - pycparser=2.21
  - pyopenssl=23.0.0
  - pyparsing=3.0.9
  - pyproj=3.4.1
  - pyqt=5.15.7
  - pyqt5-sip=12.11.0
  - pyshp=2.3.1
  - pysocks=1.7.1
  - python=3.9.15
  - python-dateutil=2.8.2
  - python_abi=3.9
  - pytz=2022.7.1
  - qt-main=5.15.6
  - rasterio=1.3.4
  - requests=2.28.2
  - rtree=1.0.1
  - scikit-learn=1.2.0
  - scipy=1.10.0
  - sentinelsat=1.1.1
  - setuptools=66.1.1
  - shapely=2.0.0
  - sip=6.7.5
  - six=1.16.0
  - snappy=1.1.9
  - snuggs=1.4.7
  - sqlite=3.40.0
  - tbb=2021.7.0
  - threadpoolctl=3.1.0
  - tiledb=2.13.2
  - tk=8.6.12
  - toml=0.10.2
  - tornado=6.2
  - tqdm=4.64.1
  - tzdata=2022g
  - ucrt=10.0.22621.0
  - unicodedata2=15.0.0
  - urllib3=1.26.14
  - vc=14.3
  - vs2015_runtime=14.34.31931
  - wheel=0.38.4
  - win_inet_pton=1.1.0
  - xarray=2023.1.0
  - xerces-c=3.2.4
  - xorg-libxau=1.0.9
  - xorg-libxdmcp=1.1.3
  - xyzservices=2022.9.0
  - xz=5.2.6
  - zlib=1.2.13
  - zstd=1.5.2

@AL89
Copy link

AL89 commented Jun 5, 2023

Hi @DevAlvaroF

Thanks for your work! I also ran into this problem recently. So I came across your solution.

However, instead of doing all this environment stuff, I just simply tried to do what you wrote in step 2, while still having rasterio 1.3.7 and latest Python version installed.

At this point you can import gdal from a normal ".py" file but not from a ".ipynb" (Jupyter Notebook)

from osgeo import gdal # Import gdal before rasterio
import rasterio

Simply import gdal before rasterio and it works for me. If it doesn't work for you still, I am sorry. But it worked for me.

@remi-braun
Copy link

remi-braun commented Jul 10, 2023

I just encountered the same issue with the latest conda build (after a conda update conda, i.e. 3.25.0) on Windows 10 and with this simple environment file:

name: rasterio_39
channels:
  - conda-forge
dependencies:         # everything under this, installed by conda
  - python=3.9
  - rasterio

Error is:

(rasterio_39) PS D:\_EXTRACTEO\BUG\conda> python
Python 3.9.16 | packaged by conda-forge | (main, Feb  1 2023, 21:28:38) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import rasterio
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\rbraun\Anaconda3\envs\rasterio_39\lib\site-packages\rasterio\__init__.py", line 28, in <module>
    from rasterio._version import gdal_version, get_geos_version, get_proj_version
ImportError: DLL load failed while importing _version: La procédure spécifiée est introuvable.
>>>

The package list is:

(rasterio_39) PS C:\Users\rbraun> conda list
# packages in environment at C:\Users\rbraun\Anaconda3\envs\rasterio_39:
#
# Name                    Version                   Build  Channel
affine                    2.4.0              pyhd8ed1ab_0    conda-forge
attrs                     23.1.0             pyh71513ae_1    conda-forge
blosc                     1.21.4               hdccc3a2_0    conda-forge
boost-cpp                 1.78.0               h9f4b32c_3    conda-forge
bzip2                     1.0.8                h8ffe710_4    conda-forge
ca-certificates           2023.5.7             h56e8100_0    conda-forge
cairo                     1.16.0            hdecc03f_1016    conda-forge
certifi                   2023.5.7           pyhd8ed1ab_0    conda-forge
cfitsio                   4.2.0                h9ebe7e4_0    conda-forge
click                     8.1.4           win_pyh7428d3b_0    conda-forge
click-plugins             1.1.1                      py_0    conda-forge
cligj                     0.7.2              pyhd8ed1ab_1    conda-forge
colorama                  0.4.6              pyhd8ed1ab_0    conda-forge
curl                      8.1.2                h68f0423_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                 hab24e00_0    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               h546665d_1    conda-forge
freexl                    1.0.6                h67ca5e6_1    conda-forge
geos                      3.12.0               h1537add_0    conda-forge
geotiff                   1.7.1                h4e61e90_9    conda-forge
gettext                   0.21.1               h5728263_0    conda-forge
hdf4                      4.2.15               h1334946_6    conda-forge
hdf5                      1.14.1          nompi_h73e8ff5_100    conda-forge
icu                       72.1                 h63175ca_0    conda-forge
intel-openmp              2023.1.0         h57928b3_46319    conda-forge
kealib                    1.5.1                h96def13_4    conda-forge
krb5                      1.20.1               heb0366b_0    conda-forge
lcms2                     2.15                 h3e3b177_1    conda-forge
lerc                      4.0.0                h63175ca_0    conda-forge
libaec                    1.0.6                h63175ca_1    conda-forge
libarchive                3.6.2                h6f8411a_1    conda-forge
libblas                   3.9.0              17_win64_mkl    conda-forge
libcblas                  3.9.0              17_win64_mkl    conda-forge
libcurl                   8.1.2                h68f0423_0    conda-forge
libdeflate                1.18                 hcfcfb64_0    conda-forge
libexpat                  2.5.0                h63175ca_1    conda-forge
libffi                    3.4.2                h8ffe710_5    conda-forge
libgdal                   3.7.0                hc47cf30_5    conda-forge
libglib                   2.76.4               he8f3873_0    conda-forge
libhwloc                  2.9.1           nocuda_h15da153_6    conda-forge
libiconv                  1.17                 h8ffe710_0    conda-forge
libjpeg-turbo             2.1.5.1              hcfcfb64_0    conda-forge
libkml                    1.3.0             hf2ab4e4_1015    conda-forge
liblapack                 3.9.0              17_win64_mkl    conda-forge
libnetcdf                 4.9.2           nompi_h5902ca5_107    conda-forge
libpng                    1.6.39               h19919ed_0    conda-forge
libpq                     15.3                 ha9684e8_1    conda-forge
librttopo                 1.1.0               h92c5fdb_14    conda-forge
libspatialite             5.0.1               hc49ff46_28    conda-forge
libsqlite                 3.42.0               hcfcfb64_0    conda-forge
libssh2                   1.11.0               h7dfc565_0    conda-forge
libtiff                   4.5.1                h6c8260b_0    conda-forge
libwebp-base              1.3.1                hcfcfb64_0    conda-forge
libxml2                   2.11.4               hc3477c8_0    conda-forge
libzip                    1.9.2                h519de47_1    conda-forge
libzlib                   1.2.13               hcfcfb64_5    conda-forge
lz4-c                     1.9.4                hcfcfb64_0    conda-forge
lzo                       2.10              he774522_1000    conda-forge
mkl                       2022.1.0           h6a75c08_874    conda-forge
numpy                     1.25.1           py39h816b6a6_0    conda-forge
openjpeg                  2.5.0                ha2aaf27_2    conda-forge
openssl                   3.1.1                hcfcfb64_1    conda-forge
pcre2                     10.40                h17e33f8_0    conda-forge
pip                       23.1.2             pyhd8ed1ab_0    conda-forge
pixman                    0.40.0               h8ffe710_0    conda-forge
poppler                   23.07.0              h45d20d0_0    conda-forge
poppler-data              0.4.12               hd8ed1ab_0    conda-forge
postgresql                15.3                 h96452e4_1    conda-forge
proj                      9.2.1                h660b3b0_0    conda-forge
pthreads-win32            2.9.1                hfa6e2cd_3    conda-forge
pyparsing                 3.1.0              pyhd8ed1ab_0    conda-forge
python                    3.9.16          h4de0772_0_cpython    conda-forge
python_abi                3.9                      3_cp39    conda-forge
rasterio                  1.3.8            py39h2a7a4f8_0    conda-forge
setuptools                68.0.0             pyhd8ed1ab_0    conda-forge
snappy                    1.1.10               hfb803bf_0    conda-forge
snuggs                    1.4.7                      py_0    conda-forge
sqlite                    3.42.0               hcfcfb64_0    conda-forge
tbb                       2021.9.0             h91493d7_0    conda-forge
tiledb                    2.13.2               h3132609_0    conda-forge
tk                        8.6.12               h8ffe710_0    conda-forge
tzdata                    2023c                h71feb2d_0    conda-forge
ucrt                      10.0.22621.0         h57928b3_0    conda-forge
vc                        14.3                h64f974e_17    conda-forge
vc14_runtime              14.36.32532         hfdfe4a8_17    conda-forge
vs2015_runtime            14.36.32532         h05e6639_17    conda-forge
wheel                     0.40.0             pyhd8ed1ab_0    conda-forge
xerces-c                  3.2.4                h63175ca_2    conda-forge
xz                        5.2.6                h8d14728_0    conda-forge
zlib                      1.2.13               hcfcfb64_5    conda-forge
zstd                      1.5.2                h12be248_7    conda-forge

The conda info lines:

(rasterio_39) PS C:\Users\rbraun> conda info

     active environment : rasterio_39
    active env location : C:\Users\rbraun\Anaconda3\envs\rasterio_39
            shell level : 2
       user config file : C:\Users\rbraun\.condarc
 populated config files : C:\Users\rbraun\.condarc
          conda version : 23.5.0
    conda-build version : 3.25.0
         python version : 3.8.17.final.0
       virtual packages : __archspec=1=x86_64
                          __cuda=12.1=0
                          __win=0=0
       base environment : C:\Users\rbraun\Anaconda3  (writable)
      conda av data dir : C:\Users\rbraun\Anaconda3\etc\conda
  conda av metadata url : None
           channel URLs : https://conda.anaconda.org/conda-forge/win-64
                          https://conda.anaconda.org/conda-forge/noarch
                          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\rbraun\Anaconda3\pkgs
                          C:\Users\rbraun\.conda\pkgs
                          C:\Users\rbraun\AppData\Local\conda\conda\pkgs
       envs directories : C:\Users\rbraun\Anaconda3\envs
                          C:\Users\rbraun\.conda\envs
                          C:\Users\rbraun\AppData\Local\conda\conda\envs
               platform : win-64
             user-agent : conda/23.5.0 requests/2.31.0 CPython/3.8.17 Windows/10 Windows/10.0.19045 solver/libmamba conda-libmamba-solver/23.5.0 libmambapy/1.4.7
          administrator : False
             netrc file : None
           offline mode : False

Note that I managed to make it work for ages, and now somehow it breaks 🤷‍♂️

@remi-braun
Copy link

I tried again with conda 3.27.+

The same environment as above still fails.
However, with:

name: rasterio_39
channels:
  - conda-forge
dependencies:         # everything under this, installed by conda
  - python=3.9
  - gdal
  - rasterio>1.3.0

I get:
2023-08-28_17h22_06

How come I need to import osgeo first to make it work ? Somebody knows ?

@ocefpaf
Copy link
Member

ocefpaf commented Aug 28, 2023

If importing osgeo before rasterio works for you it is a sign that you have some mixed installation. Maybe some packages from PyPI or an external installation of gdal.

I just tested taht env file on a fresh Windows machine, new miniforge installation, and everything works as expected.

@remi-braun
Copy link

remi-braun commented Aug 28, 2023

Everything is done on a fresh conda install sadly… as you see there is nothing install via pip as stated in the yaml
And everything worked and sudenly broke with conda 3.25.0 🤔
This is what is confusing!

@ocefpaf
Copy link
Member

ocefpaf commented Aug 28, 2023

Everything is done on a fresh conda install sadly…

You can still have some external gdal installation on your machine.

@remi-braun
Copy link

You are exactly right, it was a QGIS install that was messing with the rasterio's conda installation 😓
Maybe the versions of the two GDALs were the same before and now a discrepancy has appeared ?

However this is not ideal for us 😢
Our usecase needs the GDAL tools to be used in our everyday terminal.
We managed it by setting our QGIS/bin in the path and everything worked fine.
However this now messes with our Python environments.
Do you have any workaround about that (except for activating a conda env with gdal inside) ?

@ocefpaf
Copy link
Member

ocefpaf commented Aug 29, 2023

Do you have any workaround about that (except for activating a conda env with gdal inside) ?

I'm not an expert on QGIS but most folks I know use the one provided by conda-forge to avoid those incompatibilities.

If you need features that are not in the QGIS available in conda-forge, then you'll have to figure out a way to isolate them to avoid this conflict.

@akrherz
Copy link
Contributor

akrherz commented Dec 2, 2024

@remi-braun is this issue still valid for you?

@remi-braun
Copy link

Yes, we still need to add or remove QGIS from our PATH according to the environment we have

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests