2

我了解在安装 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.:。我假设这个pippython 绑定的安装就足够了,但它并没有解决问题:

$ 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我相信GEOSC++ 代码的编译被触发,过了一会儿它在底部停止:

    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 包的绑定之间的这个无人地带,我有点困惑。

4

1 回答 1

1

正如您所注意到的,cartopy需要Proj.4版本 >=4.9 中的 lib。在 Ubuntu(比 16.04 更新)上,您可以通过sudo apt-get install libproj-dev.

对于较旧的 Ubuntu,例如 14.04,您可以简单地从 16.04 ( xenial libproj-dev ) 下载最新的软件包并手动安装。请注意,它依赖于版本 4.9 中的 libproj9。请记住在更新旧版本之前删除它们
sudo apt-get purge libproj-dev libproj9 一旦完成,从适当架构的链接打开并下载包(从您的日志中我知道那是 amd64)。按顺序双击下载的文件librproj9libproj-dev使用 sudo dpkg -i <path_to_file>.

于 2017-06-02T16:38:22.667 回答