Python 安装 geopandas 时出错:“必须在 Anaconda 中指定 GDAL API 版本”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/54734667/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error installing geopandas:" A GDAL API version must be specified " in Anaconda
提问by Alvaro Morales
This error raised while installing geopandas. I've looking for its solution on the web, but none of them really explain what happened and how to solve it.. This is the full error:
安装 geopandas 时出现此错误。我在网上寻找它的解决方案,但没有一个真正解释发生了什么以及如何解决它..这是完整的错误:
Collecting geopandas
Using cached https://files.pythonhosted.org/packages/24/11/d77c157c16909bd77557d00798b05a5b6615ed60acb5900fbe6a65d35e93/geopandas-0.4.0-py2.py3-none-any.whl
Requirement already satisfied: shapely in c:\users\alvaro\anaconda3\envs\tfdeeplearning\lib\site-packages (from geopandas) (1.6.4.post2)
Requirement already satisfied: pandas in c:\users\alvaro\anaconda3\envs\tfdeeplearning\lib\site-packages (from geopandas) (0.20.3)
Collecting fiona (from geopandas)
Using cached https://files.pythonhosted.org/packages/3a/16/84960540e9fce61d767fd2f0f1d95f4c63e99ab5d8fddc308e8b51b059b8/Fiona-1.8.4.tar.gz
Complete output from command python setup.py egg_info:
A GDAL API version must be specified. Provide a path to gdal-config using a GDAL_CONFIG environment variable or use a GDAL_VERSION environment variable.
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\Alvaro\AppData\Local\Temp\pip-install-oxgkjg8l\fiona\
回答by Josh Friedlander
Geospatial Data Abstraction Library (GDAL) is a library designed for vector geospatial data formats. It's a prerequisite for installing Fiona, the Python API for OGR (which doesn't really stand for anything), which is in turn a prerequisite for Geopandas. On UNIX-like systems the gdal-config
script tells Fiona stuff about your particular gdal
installation.
地理空间数据抽象库 (GDAL) 是为矢量地理空间数据格式设计的库。这是安装 Fiona 的先决条件,OGR 的 Python API(实际上并不代表任何东西),而这又是 Geopandas 的先决条件。在类 UNIX 系统上,gdal-config
脚本会告诉 Fiona 有关您特定gdal
安装的信息。
It seems that your gdal-config
is not in one of the usual places on your PATH, so Fiona was unable to find it.
似乎您gdal-config
不在 PATH 上的常见位置之一,因此 Fiona 无法找到它。
If you're using Anaconda, best is to remove gdal with conda remove gdal
and then do a fresh conda install geopandas
.
如果您使用的是 Anaconda,最好是删除 gdal,conda remove gdal
然后重新创建conda install geopandas
.
As a general rule, if you're using Conda you should never use pip to install something inside it unless you're absolutely sure conda offers no support for it. (Many package can be found on conda by specifying the right channel - -c
argument.) And specifically in the case of geopandas, the maintainers recommendusing conda over pip, since pip requires you to install the dependencies correctly.
作为一般规则,如果您使用 Conda,则永远不要使用 pip 在其中安装某些东西,除非您绝对确定 conda 不提供对它的支持。(通过指定正确的通道 --c
参数可以在 conda 上找到许多包。)特别是在 geopandas 的情况下,维护人员建议使用 conda 而不是 pip,因为 pip 要求您正确安装依赖项。
回答by JDOaktown
pip install wheel
pip install pipwin
pipwin install numpy
pipwin install pandas
pipwin install shapely
pipwin install gdal
pipwin install fiona
pipwin install pyproj
pipwin install six
pipwin install rtree
pipwin install geopandas
here are the source links: http://geopandas.org/install.html#installationhttps://pip.pypa.io/en/latest/user_guide/#installing-from-wheelshttps://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy
这里是源链接: http ://geopandas.org/install.html#installation https://pip.pypa.io/en/latest/user_guide/#installing-from-wheels https://www.lfd.uci .edu/~gohlke/pythonlibs/#numpy
If you still have problems, consider uninstalling the above (pip uninstall) and reinstalling.
如果还是有问题,可以考虑卸载上面的(pip卸载)并重新安装。
回答by Devarshi Mandal
One way in which I could install geopandas was through the Anaconda Navigator. Get into the environment and install the package 'geopandas'. After that I could import the geopandas package in spyder
我可以安装 geopandas 的一种方法是通过 Anaconda Navigator。进入环境并安装包“geopandas”。之后我可以在 spyder 中导入 geopandas 包