6

I am creating a conda env with the following commands in my Windows machine:

conda create -n s1 python=3.6
conda activate s1
conda config --env --add channels conda-forge
conda config --env --set channel_priority strict

Then, I install the geopandas, rasterio, jupyterlab packages:

conda install geopandas
conda install jupyterlab
conda install raserio

If I open python from terminal and load the packages:

(s1) C:\>python
Python 3.6.13 (default, Sep  7 2021, 06:39:02) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import geopandas
>>> import rasterio

Everything works. However, if I open jupyter lab:

(s1) C:\>jupyter lab

and try to load the same packages in a code cell, I get the following error:

import rasterio


---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-350e27267e59> in <module>
----> 1 import rasterio

~\Anaconda3\envs\s1\lib\site-packages\rasterio\__init__.py in <module>
     20             pass
     21 
---> 22 from rasterio._base import gdal_version
     23 from rasterio.drivers import is_blacklisted
     24 from rasterio.dtypes import (

ImportError: DLL load failed: The specified procedure could not be found.

If I try with geopandas:

import geopandas
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-2-fc7d1d298f0c> in <module>
----> 1 import geopandas

~\Anaconda3\envs\s1\lib\site-packages\geopandas\__init__.py in <module>
      5 from geopandas.array import points_from_xy  # noqa
      6 
----> 7 from geopandas.io.file import _read_file as read_file  # noqa
      8 from geopandas.io.arrow import _read_parquet as read_parquet  # noqa
      9 from geopandas.io.arrow import _read_feather as read_feather  # noqa

~\Anaconda3\envs\s1\lib\site-packages\geopandas\io\file.py in <module>
     18 
     19 try:
---> 20     from fiona import Env as fiona_env
     21 except ImportError:
     22     try:

~\Anaconda3\envs\s1\lib\site-packages\fiona\__init__.py in <module>
     83 
     84 import fiona._loading
---> 85 with fiona._loading.add_gdal_dll_directories():
     86     from fiona.collection import BytesCollection, Collection
     87     from fiona.drvsupport import supported_drivers

AttributeError: module 'fiona' has no attribute '_loading'

What can be the reason?

--- EDIT ---

From this question I see a solution would be to remove rasterio from my conda env and install it with pip. I would be okay with it but would prefer to stay with the conda instalation

How to Fix: "ImportError: DLL load failed The specified procedure could not be found." when the DLLs are there

ChaddRobertson
  • 605
  • 3
  • 11
  • 30
GCGM
  • 901
  • 1
  • 17
  • 38
  • running `sys.executable` in Jupyter Lab gives me `'C:\\Users\\cstr\\Anaconda3\\envs\\s1\\python.exe'` So it is using the right one as it comes from the `s1` conda env. Btw, I am working on Windows – GCGM Sep 21 '21 at 06:53
  • What do you get if you run this `jupyter kernelspec list` on the terminal. Available kernels will be listed. Make sure you use the correct kernel to run your notebook. – swatchai Sep 21 '21 at 08:30
  • I get a list pointing to one kernel only, saved in the conda env I just created – GCGM Sep 30 '21 at 13:27
  • you are right in wanting to stay with conda. Using pip after switching to conda negates the whole reason of using conda for me ie "no package conflicts" – Tejas Shetty Nov 06 '21 at 05:29
  • maybe reinstall Jupyter instead – Tejas Shetty Nov 06 '21 at 05:32
  • pip has proven to be more reliable than anaconda for me and the people I work with. I can help you set everything up with pip if you want to switch over from anaconda – Yiannis Nov 08 '21 at 10:35
  • can you include the output of `conda list` in your activated environment – Paul H Dec 09 '21 at 09:43

0 Answers0