2016-11-12 862 views
2

我知道在安装cartopy和底图之前需要满足一些依赖关系。我使用pip(如numpy等)对其中的大部分进行了整理。如何使用pip安装地图/绘图库cartopy和底图

我发现有一些cartopy问题与PROJ.4和一些底图问题与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)。

我宁愿避免像蟒蛇,雨棚等 所有这些事情,如果可能的话,我想只有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: [email protected] 
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/ 
    

我不知道我在做什么错误:

  • 如何提供正确的Proj.4东西到cartopy?实际上,我宁愿找到一个较旧的版本,对现有版本的Proj.4(我假设它来自pip install绑定)有效,
  • 如何从我设置的GDAL链接中获取底图映射pip?如果这还不够,那我应该做些什么?也许一些GEOS封装的某些apt-get可以避免在底图安装中触发GEOS编译?

我有点困惑,在这个没有男人的土地之间的Java二进制文件,C++二进制文件和绑定到Python包。

回答

0

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

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

+0

这确实安装了proj4,但对我来说它拉4.8.0不4.9.0 – Daniel

+0

@Daniel我已更新条目。 –