本文介绍了导入Geopandas时出现导入错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当尝试将geopandas导入到我的jupyter笔记本中时,出现 ImportError:DLL加载失败.我已经从终端上运行 pip install geopandas 并得到需求已满足".我还尝试了 pip install --upgrade pip setuptools ,该方法也没有起作用.这是尝试导入Geopandas时的完整错误报告:

When trying to import geopandas into my jupyter notebook I get an ImportError: DLL load failed. I have already run pip install geopandas from my terminal and get "Requirement already satisfied". I have also tried pip install --upgrade pip setuptools which hasnt worked either. Here is the full error report when trying to import geopandas:

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

~\AppData\Local\Continuum\Anaconda3\lib\site-packages\geopandas\__init__.py in <module>()
      2 from geopandas.geodataframe import GeoDataFrame
      3
----> 4 from geopandas.io.file import read_file
      5 from geopandas.io.sql import read_postgis
      6 from geopandas.tools import sjoin

~\AppData\Local\Continuum\Anaconda3\lib\site-packages\geopandas\io\file.py in <module>()
      1 import os
      2
----> 3 import fiona
      4 import numpy as np
      5

~\AppData\Local\Continuum\Anaconda3\lib\site-packages\fiona\__init__.py in <module>()
     67 from six import string_types
     68
---> 69 from fiona.collection import Collection, BytesCollection, vsi_path
     70 from fiona._drivers import driver_count, GDALEnv
     71 from fiona.drvsupport import supported_drivers

~\AppData\Local\Continuum\Anaconda3\lib\site-packages\fiona\collection.py in <module>()
      7
      8 from fiona import compat
----> 9 from fiona.ogrext import Iterator, ItemsIterator, KeysIterator
     10 from fiona.ogrext import Session, WritingSession
     11 from fiona.ogrext import (

ImportError: DLL load failed: The operating system cannot run %1.

感谢所有帮助.

推荐答案

首先将conda通道添加到您的设置中(最后一个通道具有最高优先级).

First of all add conda channels to your settings (last channel has the highest priority).

conda config --add channels conda-forge
conda config --add channels defaults

然后尝试使用conda创建新环境.

Then try to create new environment using conda.

conda create -n test_python python=3.7 geopandas

就我而言,这是gdal的问题,尤其是conda-forge的最新版本(以前的版本效果很好).如果在测试环境中安装geopandas失败,则可以尝试安装 gdal 使用conda.

In my case it was a problem with gdal, especially with latest release on conda-forge (previous one works fine). If geopandas installation in test environment fails you can try to install this release (win64) of gdal using conda.

conda install "downloaded file path"

这篇关于导入Geopandas时出现导入错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-22 14:45