【问题标题】:Import Error: geopandas fiona or pyogorio package using conda/jupyterlab导入错误:使用 conda/jupyterlab 的 geopandas fiona 或 pyogorio 包
【发布时间】:2023-02-14 04:02:34
【问题描述】:

我正在尝试按照此处的 GEDI 遥感数据教程进行操作:https://git.earthdata.nasa.gov/projects/LPDUR/repos/gedi-V2-tutorials/browse/GEDI_L2B_V2_Tutorial.ipynb

我在命令提示符窗口中使用 conda 安装软件包并使用以下代码设置 Juptyerlab 笔记本:

conda create --name gedi python=3.9
conda activate geditutorial
conda install -c conda-forge geoviews=1.9.6
conda install --channel conda-forge geopandas=0.12.2
conda install -c conda-forge h5py=3.8.0
conda install -c conda-forge jupyterlab=3.5.3

当我到达“In [22]: Import a GeoJSON of Redwood National Park as an additional GeoDataFrame”时,出现以下错误:

Cell In[21], line 1
----> 1 redwoodNP = gp.GeoDataFrame.from_file('RedwoodNP.geojson')  # Import GeoJSON as GeoDataFrame

File ~\anaconda3\envs\geditutorial\lib\site-packages\geopandas\geodataframe.py:556, in GeoDataFrame.from_file(cls, filename, **kwargs)
    507 @classmethod
    508 def from_file(cls, filename, **kwargs):
    509     """Alternate constructor to create a ``GeoDataFrame`` from a file.
    510 
    511     It is recommended to use :func:`geopandas.read_file` instead.
   (...)
    554 
    555     """
--> 556     return geopandas.io.file._read_file(filename, **kwargs)

File ~\anaconda3\envs\geditutorial\lib\site-packages\geopandas\io\file.py:242, in _read_file(filename, bbox, mask, rows, engine, **kwargs)
    172 def _read_file(filename, bbox=None, mask=None, rows=None, engine=None, **kwargs):
    173     """
    174     Returns a GeoDataFrame from a file or URL.
    175 
   (...)
    240     by using the encoding keyword parameter, e.g. ``encoding='utf-8'``.
    241     """
--> 242     engine = _check_engine(engine, "'read_file' function")
    244     filename = _expand_user(filename)
    246     from_bytes = False

File ~\anaconda3\envs\geditutorial\lib\site-packages\geopandas\io\file.py:112, in _check_engine(engine, func)
    110     _check_pyogrio(func)
    111 elif engine is None:
--> 112     raise ImportError(
    113         f"The {func} requires the 'pyogrio' or 'fiona' package, "
    114         "but neither is installed or imports correctly."
    115         f"\nImporting fiona resulted in: {fiona_import_error}"
    116         f"\nImporting pyogrio resulted in: {pyogrio_import_error}"
    117     )
    119 return engine

ImportError: The 'read_file' function requires the 'pyogrio' or 'fiona' package, but neither is installed or imports correctly.
Importing fiona resulted in: DLL load failed while importing _env: The specified procedure could not be found.
Importing pyogrio resulted in: No module named 'pyogrio'

我尝试使用 conda 安装 pyogrio 和 fiona,但出现有关包目录的错误:

  File "C:\Users\me\anaconda3\lib\site-packages\conda\exceptions.py", line 1238, in print_unexpected_error_report
    message_builder.append(get_main_info_str(error_report['conda_info']))
  File "C:\Users\me\anaconda3\lib\site-packages\conda\cli\main_info.py", line 236, in get_main_info_str
    info_dict['_' + key] = ('\n' + 26 * ' ').join(info_dict[key])
KeyError: 'pkgs_dirs'

一般来说,我对遥感、Python 和命令行非常陌生,所以如果能帮助我安装 fiona 或 pyogrio,这样我就不会收到这个错误,我将不胜感激!

【问题讨论】:

    标签: python conda geopandas


    【解决方案1】:

    解决了!在安装任何其他软件包之前,我重建了我的 conda 环境并使用 conda-forge 安装了 fiona 和 pyogrio 并且它起作用了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-11-29
      • 2019-09-10
      • 2022-11-30
      • 2021-12-16
      • 2018-11-02
      • 2021-04-11
      • 2018-08-14
      相关资源
      最近更新 更多