Python 如何成功安装pyproj和geopandas?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34427788/
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
how to successfully install pyproj and geopandas?
提问by user3144095
I have tried to install geopandas via I python by running !pip install geopandas, but this fails with "python setup.py egg_info" failed with error code 1 and then Path to long directory. I read online that pyproj is required for geopandas and also tried to install it however no luck, similar error. Would anyone be able to point me in the right direction? Thank you.
我试图通过运行 !pip install geopandas 通过我的 python 安装 geopandas,但这失败了“python setup.py egg_info”失败,错误代码为 1,然后是长目录的路径。我在网上读到 geopandas 需要 pyproj 并尝试安装它,但是没有运气,类似的错误。有人能指出我正确的方向吗?谢谢你。
Oh by the way, if this helps, I was able to install shapely, fiona, and Descartes using this method.
哦,顺便说一句,如果这有帮助,我可以使用这种方法安装匀称、菲奥娜和笛卡尔。
回答by Marcus Williams
On Windows, I download (from http://www.lfd.uci.edu/~gohlke/pythonlibs/) and install the .whl files for GDAL, Fiona, pyproj, Shapely and Rtree using the command
在 Windows 上,我下载(从http://www.lfd.uci.edu/~gohlke/pythonlibs/)并使用命令安装 GDAL、Fiona、pyproj、Shapely 和 Rtree 的 .whl 文件
pip install filename.whl
for each .whl file.
对于每个 .whl 文件。
As a final step I run
作为最后一步,我跑
pip install https://github.com/geopandas/geopandas/archive/master.zip
because I want the dev version of geopandas. The conda w/ ioos method looks easier - but I haven't tried it yet.
因为我想要 geopandas 的开发版本。conda w/ ioos 方法看起来更简单 - 但我还没有尝试过。
回答by Philipp Schwarz
Getting to work geopandas is unfortuntaly not easy, the problem is that the dependencies are partly not working and you have to use older versions of Fiona and GDAL. The following packages work stable together:
不幸的是,开始使用 geopandas 并不容易,问题是依赖项部分不起作用,您必须使用旧版本的 Fiona 和 GDAL。以下软件包可以稳定地协同工作:
GDAL: 1.11.2
Fiona: 1.6.0
Geopandas: 0.1.0.dev-
To install on ubuntu:
在 ubuntu 上安装:
sudo apt-get install build-essential python-all-dev
wget http://download.osgeo.org/gdal/1.11.2/gdal-1.11.2.tar.gz
tar xvfz gdal-1.11.2.tar.gz
cd gdal-1.11.2
./configure --with-python
make
sudo make install
In addition, some Linux distributions require the shared library cache to be updated after install:
此外,一些 Linux 发行版需要在安装后更新共享库缓存:
sudo ldconfig
Fiona and geopandas can be installed classic by:
Fiona 和 geopandas 可以通过以下方式安装经典:
sudo pip install Fiona==1.6.0
sudo pip install geopandas
Under windows
窗户下
As @Marcus Williams states:
正如@Marcus Williams 所说:
Download Fiona and GDAL Windows Binaries corresponding your python environment (32, 64bit and 2.7 3.3 etc. (from http://www.lfd.uci.edu/~gohlke/pythonlibs/) and go in cmd with cd to directory where downloaded files are and install the .whl files using the command
下载与您的 python 环境(32、64 位和 2.7 3.3 等)相对应的 Fiona 和 GDAL Windows 二进制文件(来自http://www.lfd.uci.edu/~gohlke/pythonlibs/)并使用 cd 进入 cmd 到下载文件的目录是并使用命令安装 .whl 文件
pip install filename.whl
Finally:
最后:
pip install geopandas
回答by joris
Thanks to the conda-forge community, geopandas
is actually pretty easy to install on all platforms using the conda package manager(or: its dependencies, as this is the difficulty).
感谢conda-forge 社区,geopandas
使用conda 包管理器(或:它的依赖项,因为这是困难)实际上很容易在所有平台上安装。
If you have conda, it is just:
如果你有 conda,它只是:
conda install -c conda-forge geopandas
To install conda, you can install the Anaconda python distribution or miniconda: http://conda.pydata.org/docs/download.html
要安装 conda,您可以安装 Anaconda python 发行版或 miniconda:http://conda.pydata.org/docs/download.html
See the GeoPandas docs for more details, specifically on how to create a new environment with GeoPandas installed with settings to ensure this always works: https://geopandas.org/install.html#creating-a-new-environment
有关更多详细信息,请参阅 GeoPandas 文档,特别是关于如何使用安装了设置的 GeoPandas 创建新环境以确保始终有效:https://geopandas.org/install.html#creating-a-new-environment
回答by Sulduzlu
problem(Windows 10 x64, Python 3.4+):
问题(Windows 10 x64,Python 3.4+):
1.Install Visual C++ 2010 Express (download). (Do not install Microsoft Visual Studio 2010 Service Pack 1 )
1.安装Visual C++ 2010 Express(下载)。(不要安装 Microsoft Visual Studio 2010 Service Pack 1 )
2.Remove all the Microsoft Visual C++ 2010 Redistributable packages from Control Panel\Programs and Features. If you don't do those then the install is going to fail with an obscure "Fatal error during installation" error.
2.从控制面板\程序和功能中删除所有 Microsoft Visual C++ 2010 Redistributable 包。如果你不这样做,那么安装将会失败,并出现一个模糊的“安装过程中的致命错误”错误。
then: pip install pyproj
然后: pip install pyproj
回答by Andreas Schmidt
回答by Kevin
After hours of failure (with WinError 126, "not a supported wheel on this platform" error, etc.), I've successfully installed pyproj and geopandas, and this is what I did:
经过数小时的失败(WinError 126、“此平台上不支持轮子”错误等),我已经成功安装了 pyproj 和 geopandas,这就是我所做的:
Install descartes, pandas, fiona, shapely, pyproj first as they're required for geopandas.
For descartes and pandas, installation could be done directly with 'pip install descartes' or 'pip install pandas' from command line.
For fiona, shapely, pyproj:
Download the corresponding .whl for your python version (e.g. Fiona-1.7.8-cp34-cp34m-win32.whl for Python 3.4). Important: download win32 version only, as win_amd64 version did not work (God knows why)
- Install each package with 'pip install <path to download folder>Fiona-1.7.8-cp34-cp34m-win32.whl'
- For geopandas:
- Download its .whl file from https://pypi.python.org/pypi/geopandas/0.2.1
- Install geopandas using the same command line as with fiona, shapely, pyproj.
首先安装 descartes、pandas、fiona、shapely、pyproj,因为 geopandas 需要它们。
对于 descartes 和 pandas,可以直接从命令行使用 'pip install descartes' 或 'pip install pandas' 完成安装。
对于菲奥娜,匀称,pyproj:
为您的 Python 版本下载相应的 .whl(例如 Python 3.4 的 Fiona-1.7.8-cp34-cp34m-win32.whl)。重要提示:仅下载 win32 版本,因为 win_amd64 版本不起作用(天知道为什么)
- 使用 'pip install < path to download folder>Fiona-1.7.8-cp34-cp34m-win32.whl'安装每个包
- 对于大熊猫:
- 从https://pypi.python.org/pypi/geopandas/0.2.1下载其 .whl 文件
- 使用与 fiona、shapely、pyproj 相同的命令行安装 geopandas。
回答by Vesanen
I recently destroyed my Anaconda 5.2 distribution by trying to upgrade from Geopandas 0.3.0 to 0.4.0. I didn't notice, that command conda install -c conda-forge geopandas
wanted to upgrade a bunch of packages, downgrade others and remove Anaconda 5.2.
我最近尝试从 Geopandas 0.3.0 升级到 0.4.0,破坏了我的 Anaconda 5.2 发行版。我没有注意到,该命令conda install -c conda-forge geopandas
想要升级一堆软件包,降级其他软件包并删除 Anaconda 5.2。
Anyway, after reinstalling Anaconda 5.2 I ran into several Command "python setup.py egg_info" failed with error code 1 in <filepath>
errors with no ways around it. I even tried installing Anaconda 5.2 on a different computer, still same error message.
无论如何,在重新安装 Anaconda 5.2 后,我遇到了几个Command "python setup.py egg_info" failed with error code 1 in <filepath>
无法解决的错误。我什至尝试在另一台计算机上安装 Anaconda 5.2,仍然出现相同的错误消息。
I then stumbled on this website Geoff Boeing: Using geopandas on Windows. It did the trick for me. In case this link stops functioning at some point, I'll just copy-paste the contents below.
然后我偶然发现了这个网站GeoffBoeing: Using geopandas on Windows。它对我有用。如果此链接在某些时候停止运行,我将复制粘贴下面的内容。
My notes: I installed cp36-versions from Gohlke as Anaconda 5.2 comes with Python 3.6.5. My Anaconda installation was installed by default to C:\Users\<Username>\AppData\Local\Continuum\anaconda3\Lib\site-packages
so I used that as the environment variable.
我的笔记:我从 Gohlke 安装了 cp36 版本,因为 Anaconda 5.2 随附 Python 3.6.5。我的 Anaconda 安装默认安装为,C:\Users\<Username>\AppData\Local\Continuum\anaconda3\Lib\site-packages
因此我将其用作环境变量。
Installing geopandas and its dependencies manually
手动安装 geopandas 及其依赖项
- First and most important: do not try to directly
pip install
orconda install
any of the dependencies – if you do, they will fail in some way later, often silently or obscurely, making troubleshooting difficult. If any are already installed, uninstall them now. - Download the wheels for GDAL, Fiona, pyproj, rtree, and shapelyfrom Gohlke. Make sure you choose the wheel files that match your architecture (64-bit) and Python version (2.7 or 3.x). If Gohlke mentions any prerequisites in his descriptions of those 5 packages, install the prerequisites now (there might be a C++ redistributable or something similar listed there)
- If OSGeo4W, GDAL, Fiona, pyproj, rtree, or shapely is already installed, uninstall it now. The GDAL wheel contains a complete GDAL installation – don't use it alongside OSGeo4W or other distributions.
- Open a command prompt and change directories to the folder where you downloaded these 5 wheels.
pip install
the GDAL wheel file you downloaded. Your actual command will be something like:pip install GDAL-1.11.2-cp27-none-win_amd64.whl
- Add the new GDAL path to the windows PATHenvironment variable,
something like
C:\Anaconda\Lib\site-packages\osgeo
pip install
your Fiona wheel file, then your pyproj wheel file, then rtree, and then shapely.- Now that GDAL and geopandas's dependencies are all installed, you
can just
pip install geopandas
from the command prompt
- 首先也是最重要的:不要尝试直接
pip install
或conda install
任何依赖项——如果你这样做,它们以后会以某种方式失败,通常是默默地或隐蔽地,使故障排除变得困难。如果已安装,请立即卸载它们。 - 下载车轮GDAL,菲奥娜,pyproj, RTREE和匀称从Gohlke。确保选择与您的架构(64 位)和 Python 版本(2.7 或 3.x)相匹配的轮文件。如果 Gohlke 在他对这 5 个软件包的描述中提到任何先决条件,请立即安装先决条件(可能有 C++ 可再发行组件或类似的东西)
- 如果已经安装了 OSGeo4W、GDAL、Fiona、pyproj、rtree 或 shapely,请立即卸载。GDAL 轮包含完整的 GDAL 安装 - 不要将它与 OSGeo4W 或其他发行版一起使用。
- 打开命令提示符并将目录更改为下载这 5 个轮子的文件夹。
pip install
您下载的 GDAL 轮文件。您的实际命令将类似于:pip install GDAL-1.11.2-cp27-none-win_amd64.whl
- 将新的 GDAL 路径添加到 windows PATH环境变量中,类似于
C:\Anaconda\Lib\site-packages\osgeo
pip install
你的 Fiona 轮文件,然后是你的 pyproj 轮文件,然后是 rtree,然后是匀称的。- 现在GDAL和geopandas的依赖都安装好了,你可以直接
pip install geopandas
从命令提示符
Update 21/03/2020:as of Anaconda 2020.02, rtree is now included in the distribution.
2020 年 3 月 21 日更新:从 Anaconda 2020.02 开始,rtree 现已包含在发行版中。
回答by PIYUSH AGGARWAL
To install geopandas on windows, you need to follow the below-mentioned steps: -
要在 Windows 上安装 geopandas,您需要按照以下步骤操作:-
You need to install GDAL wheel file using the link https://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal. After visiting this link, download this file named "GDAL?3.0.4?cp37?cp37m?win32.whl" since it worked for me and then use the command "pip install c:\Users........\GDAL?3.0.4?cp37?cp37m?win32.whl" to successfully install GDAL which is the requirement of Geopandas.
After installing the GDAL, you need to install a Fiona wheel file using the link https://www.lfd.uci.edu/~gohlke/pythonlibs/#fiona. Upon visiting this link, download the file named "Fiona?1.8.13?cp37?cp37m?win32.whl" since it is the supported wheel file for most of the windows users. After downloading this file, use the command "pip install c:\Users........\Fiona?1.8.13?cp37?cp37m?win32.whl".
Lastly, run the command "pip install geopandas" and you are good to go!
您需要使用链接https://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal安装 GDAL 轮文件。访问此链接后,下载名为“GDAL?3.0.4?cp37?cp37m?win32.whl”的文件,因为它对我有用,然后使用命令“pip install c:\Users........\ GDAL?3.0.4?cp37?cp37m?win32.whl”以成功安装Geopandas要求的GDAL。
安装 GDAL 后,您需要使用链接https://www.lfd.uci.edu/~gohlke/pythonlibs/#fiona安装 Fiona 轮文件。访问此链接后,下载名为“Fiona?1.8.13?cp37?cp37m?win32.whl”的文件,因为它是大多数 Windows 用户支持的轮文件。下载此文件后,使用命令“pip install c:\Users........\Fiona?1.8.13?cp37?cp37m?win32.whl”。
最后,运行命令“pip install geopandas”,一切顺利!
NOTE: If the above-mentioned wheel file doesn't work for you, then try using alternate wheel files.
注意:如果上述车轮文件对您不起作用,请尝试使用备用车轮文件。
回答by Akash Desai
When using pip to install GeoPandas, you need to make sure that all dependencies are installed correctly.
使用 pip 安装 GeoPandas 时,需要确保所有依赖项都安装正确。
First install shapely, fiona, pyproj and rtree
Then you install geopandas
首先安装 shapely、fiona、pyproj 和 rtree
然后安装 geopandas
shapely and fiona provide binary wheels with the dependencies included for Mac and Linux, but not for Windows.
shapely 和 fiona 提供二进制轮子,其中包含 Mac 和 Linux 的依赖项,但不包括 Windows。
pyproj provides binary wheels with depencies included for Mac, Linux, and Windows.
pyproj 提供二进制轮子,其中包含适用于 Mac、Linux 和 Windows 的依赖项。
rtree does not provide wheels.
rtree 不提供轮子。
pip install fiona, Pip install shapely,pyproj,rtree
pip install fiona,pip install 匀称,pyproj,rtree
回答by Brian
I was running into this same problem (it might not be fully over) but I'll show you what I did. I basically did the same things that a lot of people had mentioned and then by accident stumbled upon something that worked well.
我遇到了同样的问题(可能还没有完全结束),但我会告诉你我做了什么。我基本上做了很多人提到的同样的事情,然后偶然发现了一些运作良好的事情。
Steps involved:
涉及的步骤:
- Remove the following packages: fiona, gdal, pyproj, geoplot, rtree via the command 'conda remove fiona' etc. in Anaconda Prompt
- Install geoplot in Anaconda Prompt: conda install geoplot -c conda-forge
- 在 Anaconda Prompt 中通过命令“conda remove fiona”等删除以下包:fiona、gdal、pyproj、geoplot、rtree
- 在 Anaconda Prompt 中安装 geoplot: conda install geoplot -c conda-forge
This has geopandas and all it's dependencies built into it (fiona, gdal, pyproj, etc). I'm not sure this is an ultimate fix but it worked for me! If this doesn't work for you, I would recommend following Vesanen's instructions as that also worked for me for awhile. The problem I ran into was once I had geopandas installed I couldn't install the package geoplot without Spyder crashing.
这有 geopandas 和它内置的所有依赖项(fiona、gdal、pyproj 等)。我不确定这是一个终极修复,但它对我有用!如果这对您不起作用,我建议您遵循 Vesanen 的说明,因为这对我也适用了一段时间。我遇到的问题是,一旦安装了 geopandas,我就无法在 Spyder 崩溃的情况下安装 geoplot 包。