无法加载模块 Jupyter 但不在终端中

GCG*_*CGM 5 python geopandas jupyter-notebook rasterio jupyter-lab

我正在 Windows 计算机中使用以下命令创建 conda env:

conda create -n s1 python=3.6
conda activate s1
conda config --env --add channels conda-forge
conda config --env --set channel_priority strict
Run Code Online (Sandbox Code Playgroud)

然后,我安装geopandas, rasterio, jupyterlab软件包:

conda install geopandas
conda install jupyterlab
conda install raserio
Run Code Online (Sandbox Code Playgroud)

如果我从终端打开 python 并加载包:

(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
Run Code Online (Sandbox Code Playgroud)

一切正常。但是,如果我打开jupyter lab

(s1) C:\>jupyter lab
Run Code Online (Sandbox Code Playgroud)

并尝试在代码单元中加载相同的包,我收到以下错误:

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.
Run Code Online (Sandbox Code Playgroud)

如果我尝试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'
Run Code Online (Sandbox Code Playgroud)

可能是什么原因?

- - 编辑 - -

从这个问题我看到一个解决方案是rasterio从我的 conda env 中删除并使用pip. 我可以接受,但更愿意继续使用 conda 安装

如何修复:“导入错误:DLL 加载失败,找不到指定的过程。” 当 DLL 存在时