我正在尝试从pip install gdal虚拟环境(Ubuntu)中的pip安装gdal .它失败了,因为找不到cpl_port.h
extensions/gdal_wrap.cpp:2853:22: fatal error: cpl_port.h: No such file or directory
compilation terminated
Run Code Online (Sandbox Code Playgroud)
但是,正确安装了GDAL并且头文件位于/usr/include/gdal/cpl_port.h.是否有一些GDAL的环境变量需要设置才能让pip找到头文件?
小智 22
正如在另一个线程中所建议的那样,在运行pip之前导出一些shell变量可以完美地工作.*_INCLUDE_PATH可以找到一条路径gdal-config --cflags.
# GDAL library must have been installed
sudo apt-get install libgdal-dev
# Set up pip and/or virtualenv stuff
...
# Now install Python binding for GDAL
export CPLUS_INCLUDE_PATH=/usr/include/gdal
export C_INCLUDE_PATH=/usr/include/gdal
pip install GDAL
Run Code Online (Sandbox Code Playgroud)
小智 8
摘自此评论,它直接解决了我的问题
\n\npip3 install GDAL==$(gdal-config --version) \nRun Code Online (Sandbox Code Playgroud)\n\n显式版本号应与您现有的 libgdal 版本匹配。\xe2\x80\x93
\nTomyun的回答对我有用,条件是你必须确保安装的GDAL-dev apt-get版本与安装的版本相匹配pip.
对于Ubuntu 14.04,命令是:
# GDAL library must have been installed
sudo apt-get install libgdal-dev
# Set up pip and/or virtualenv stuff
...
# Now install Python binding for GDAL
export CPLUS_INCLUDE_PATH=/usr/include/gdal
export C_INCLUDE_PATH=/usr/include/gdal
pip3 install GDAL=1.10.0
Run Code Online (Sandbox Code Playgroud)
使用PIP:
pip install --no-install GDAL
Run Code Online (Sandbox Code Playgroud)
然后进入ENV/build/GDAL
python setup.py build_ext --include-dirs=/usr/include/gdal
pip install --no-download GDAL
Run Code Online (Sandbox Code Playgroud)
(来源:http://ubuntuforums.org/showthread.php?t = 1769445)
使用Buildout:
[gdal-bindings]
recipe = zc.recipe.egg:custom
egg = GDAL==1.9.1
include-dirs = /usr/include/gdal
library-dirs = /usr/lib
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
27574 次 |
| 最近记录: |