我了解在安装 cartopy 和底图之前需要满足一些依赖项。pip
我使用(如numpy
等)整理了其中大部分。
我发现 Proj.4 存在一些cartopy问题,而 GEOS 存在一些底图问题。我认为 python 绑定到 Java 项目 Proj.4 就足够了,我对 C++ 库 GEOS 有点迷失(我认为 GDAL 对 GEOS 来说已经足够了,我已经通过这种方式将它链接到 python 世界:)pip install --global-option=build_ext --global-option="-I/usr/include/gdal" GDAL==`gdal-config --version
。
我宁愿避免所有这些东西,如 anaconda、canopy 等。如果可能的话,我只想pip
在 Ubuntu ( apt-get
,仅当pip
还不够时) 和 Mac OSX (自制软件,例如brew install <some_package>
,仅当pip
还不够时) 上使用。
cartopy卡在一个太旧的 Proj.4 版本上。pip
输出说Proj4 version 4.8.0 is installed, but cartopy requires at least version 4.9.0.
:。我假设这个pip
python 绑定的安装就足够了,但它并没有解决问题:
$ pip show pyproj
Name: pyproj
Version: 1.9.5.1
Summary: Python interface to PROJ.4 library
Home-page: https://github.com/jswhit/pyproj
Author: Jeff Whitaker
Author-email: jeffrey.s.whitaker@noaa.gov
License: OSI Approved
Location: /usr/local/lib/python2.7/dist-packages
Requires:
我不明白为什么 python 绑定到 Proj.4 是不够的,即使这些绑定是使用pip
.
底图以不同的方式卡住:
- 以
pip2 install basemap
某种方式使用我得到Could not find a version that satisfies the requirement basemap (from versions: ) No matching distribution found for basemap
但是从底图文档中我发现由于
pip
某种原因该库没有链接到存储库,需要从源代码安装。所以我跑了:pip2 install https://github.com/matplotlib/basemap/archive/v1.0.7rel.tar.gz
我相信GEOS
C++ 代码的编译被触发,过了一会儿它在底部停止:In file included from src/_geoslib.c:255:0: /usr/include/geos_c.h:151:22: note: expected ‘GEOSMessageHandler’ but argument is of type ‘void (*)(char *, char *)’ extern void GEOS_DLL initGEOS(GEOSMessageHandler notice_function, ^ x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/src/_geoslib.o -lgeos_c -lgeos -o build/lib.linux-x86_64-2.7/_geoslib.so /usr/bin/ld: cannot find -lgeos collect2: error: ld returned 1 exit status /usr/bin/ld: cannot find -lgeos collect2: error: ld returned 1 exit status error: Command "x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/src/_geoslib.o -lgeos_c -lgeos -o build/lib.linux-x86_64-2.7/_geoslib.so" failed with exit status 1 ---------------------------------------- Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-QVrKRr-build/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-EgAOPT-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-QVrKRr-build/
我不确定我做错了什么:
- 如何为 cartopy 提供正确的 Proj.4 东西?实际上,我更愿意找到与现有 Proj.4 版本兼容的旧版本 cartopy(我假设它来自
pip install
绑定) - 如何从我设置的 GDAL 链接中获取底图查找 GEOS
pip
?如果这还不够,那我还应该做些什么呢?也许是一些apt-get
避免在底图安装中触发 GEOS 编译的 GEOS 包?
在 Java 二进制文件、C++ 二进制文件和与 python 包的绑定之间的这个无人地带,我有点困惑。