gpt4 book ai didi

python - 导入 geopandas 时出错

转载 作者:太空狗 更新时间:2023-10-29 21:38:54 24 4
gpt4 key购买 nike

导入时出现以下错误

import geopandas as gpd

---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-3-f8b81fe8ca07> in <module>()
----> 1 import geopandas as gpd

//anaconda/lib/python2.7/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

//anaconda/lib/python2.7/site-packages/geopandas/io/file.py in <module>()
1 import os
2
----> 3 import fiona
4 import numpy as np
5 from shapely.geometry import mapping

//anaconda/lib/python2.7/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

//anaconda/lib/python2.7/site-packages/fiona/collection.py in <module>()
6 import warnings
7
----> 8 from fiona import compat
9 from fiona.ogrext import Iterator, ItemsIterator, KeysIterator
10 from fiona.ogrext import Session, WritingSession

ImportError: cannot import name compat

我已经使用 anaconda 安装了 geoPandas,但是当我尝试运行它时,它显示了上述错误。运行时

conda list

我得到了

enter image description here

以下运行后:

conda install -c conda-forge fiona shapely pyproj rtree
conda install pandas
conda install -c conda-forge geopandas

我得到了

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

//anaconda/lib/python2.7/site-packages/geopandas/__init__.pyc 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

//anaconda/lib/python2.7/site-packages/geopandas/io/file.py in <module>()
1 import os
2
----> 3 import fiona
4 import numpy as np
5 from shapely.geometry import mapping

//anaconda/lib/python2.7/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

//anaconda/lib/python2.7/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: dlopen(//anaconda/lib/python2.7/site-packages/fiona/ogrext.so,

2): Library not loaded: @rpath/libnetcdf.11.dylib
Referenced from: //anaconda/lib/libgdal.20.dylib
Reason: Incompatible library version: libgdal.20.dylib requires version

12.0.0 or later, but libnetcdf.11.dylib provides version 11.0.0

最佳答案

问题是fiona和gdal的依赖不兼容导致的。通过 conda 卸载 geopandas。它还将卸载 fiona。做 conda uninstall geopandas;执行 conda install fiona=1.6

事先执行 conda search fiona 并查看它是否适用于您的 python 版本。如果不是,请为该版本的 python 创建新环境。(例如 create -n py35 python=3.5 anaconda)

然后pip install geopandas

最后,尝试import geopandas,看看是否仍然出现错误。

关于python - 导入 geopandas 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42749254/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com