Geo*_*Com 11 python pip virtualenv gdal virtualenvwrapper
我试图在virtualenvwrapper环境中安装gdal(pip install gdal),但是我收到了这个错误:
error: command 'gcc' failed with exit status 1
----------------------------------------
Failed building wheel for gdal
Failed to build gdal
Run Code Online (Sandbox Code Playgroud)
我也试过"pip install --no-install GDAL",但没有选择--no-install
我该怎么办 !?
med*_*y56 24
是的,在venv中安装GDAL是一件很麻烦的事.方便的是,我刚刚写了关于如何为我的顾问实验室这样做的文档!虽然我不够精明,无法确定错误的确切原因,但我可以给你一些东西来试图解决它.
首先,确保在主机上安装了gdal(即不在venv中).我只是运行以下内容:
sudo apt-get install libgdal1i libgdal1-dev libgdal-dev
Run Code Online (Sandbox Code Playgroud)
现在运行gdal-config --version以获取apt-get为您提供的版本.比如我得到了1.11.3
现在,根据我的经验,在venv中获取python绑定的最简单方法就是使用pygdal.诀窍是获得正确的版本!为此,请激活您的虚拟环境并运行
pip install pygdal==1.11.3
Run Code Online (Sandbox Code Playgroud)
但用你得到的任何东西取代版本gdal-config --version.注意:您可能会收到错误消息
Could not find a version that satisfies the requirement pygdal==1.11.3 (from versions: 1.8.1.0, 1.8.1.1, 1.8.1.2, 1.8.1.3, 1.9.2.0, 1.9.2.1, 1.9.2.3, 1.10.0.0, 1.10.0.1, 1.10.0.3, 1.10.1.0, 1.10.1.1, 1.10.1.3, 1.11.0.0, 1.11.0.1, 1.11.0.3, 1.11.1.0, 1.11.1.1, 1.11.1.3, 1.11.2.1, 1.11.2.3, 1.11.3.3, 1.11.4.3, 2.1.0.3) No matching distribution found for pygdal==1.11.3
Run Code Online (Sandbox Code Playgroud)
如果发生这种情况,请pip install再次运行,但使用仍然匹配的最高版本.例如,在这种情况下你会跑pip install pygdal==1.11.3.3
一旦pygdal成功安装,您应该可以打电话
>>> from osgeo import gdal
Run Code Online (Sandbox Code Playgroud)
如果有任何失败,请告诉我,我会尽我所能来调整我的指示.此外,如果您需要Proj.4,GEOS或Cartopy的帮助,我也有一些经验.
使用pygdal
pd@asghar:~$sudo apt-get install python3-gdal
pd@asghar:~$ virtualenv -p python3 test
Running virtualenv with interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in /home/pd/test/bin/python3
Also creating executable in /home/pd/test/bin/python
Installing setuptools, pip, wheel...done.
pd@asghar:~$ gdal-config --version
2.1.3
pd@asghar:~$ test/bin/pip install pygdal==2.1.3
Collecting pygdal==2.1.3
Could not find a version that satisfies the requirement pygdal==2.1.3 (from versions: 1.8.1.0, 1.8.1.1, 1.8.1.2, 1.8.1.3, 1.9.2.0, 1.9.2.1, 1.9.2.3, 1.10.0.0, 1.10.0.1, 1.10.0.3, 1.10.1.0, 1.10.1.1, 1.10.1.3, 1.11.0.0, 1.11.0.1, 1.11.0.3, 1.11.1.0, 1.11.1.1, 1.11.1.3, 1.11.2.1, 1.11.2.3, 1.11.3.3, 1.11.4.3, 1.11.5.3, 2.0.0.3, 2.0.1.3, 2.0.2.3, 2.0.3.3, 2.1.0.3, 2.1.1.3, 2.1.2.3, 2.1.3.3, 2.2.0.3)
No matching distribution found for pygdal==2.1.3
pd@asghar:~$ test/bin/pip install pygdal==2.1.3.3
Collecting pygdal==2.1.3.3
Collecting numpy>=1.0.0 (from pygdal==2.1.3.3)
Using cached numpy-1.13.1-cp35-cp35m-manylinux1_x86_64.whl
Installing collected packages: numpy, pygdal
Successfully installed numpy-1.13.1 pygdal-2.1.3.3
pd@asghar:~$ source test/bin/activate
(test) pd@asghar:~$ python
Python 3.5.2 (default, Nov 17 2016, 17:05:23)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from osgeo import gdal
>>>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6871 次 |
| 最近记录: |