Mapnik 编译安装过程

首先总结一下,Linux(windows上没有测试过)上Mapnik的编译与测试就是一部心酸血泪史呀,如果您没有做好思想准备,那就出门左转,看点有意思的去吧,编译这个太煎熬了。

安装PostgreSQL

  apt-get install

  postrgresql \ #- core database server

  postgresql-client \ #- client libraries and client binaries

  postgresql-server-dev-all \ #- libraries and headers for C language backend development

  postgresql-contrib \ # - additional supplied modules

  libpq-dev \ #- libraries and headers for C language frontend development

  pgadmin3 \ #- pgAdmin III graphical administration utility

安装PostGIS

  apt-get install 

postgresql-9.4-postgis

安装sqlite
apt-get install libsqlite-dev

安装proj4
apt-get install libproj-dev

安装tiff
apt-get install libtiff-dev 或者 libtiff5-dev

安装GDAL

  apt-get install libgdal-dev

1. Mapnik 简介

  Mapnik的官网做的那个简陋,我就不说了,在上面处理下载什么消息都得不到,我也是醉了,最后在githut的Mapnik wiki找到了简介相关文档,包括如何安装,如何测试。

https://github.com/mapnik/mapnik/wiki

Mapnik 编译安装过程

pkg-config

https://github.com/mapnik/mapnik/wiki/InstallationTroubleshooting

https://github.com/mapnik/mapnik/wiki/DebianInstallation

问题 1
   - freetype-config (freetype-config program | try setting FREETYPE_CONFIG SCons option or configure with FREETYPE_LIBS & FREETYPE_INCLUDES)
  freetype:http://download.savannah.gnu.org/releases/freetype/
  version:freetype-2.6.2.tar.gz

 

问题 2  - harfbuzz (HarfBuzz text shaping library | configure with HB_LIBS & HB_INCLUDES)

  harfbuzz : http://www.freedesktop.org/software/harfbuzz/release/

  version: harfbuzz-1.1.3.tar.bz2

 在安装harfbuzz源码时总是不能将freetype编译进去,原因是编译器找不到开发版本的freetype环境,如果非要使用自己编译的源码freetype,可以参考:Debian 入门安装与配置2,其实在harfbuzz的目录中,官方提供了BUILD.md文件,其中提示相关依赖的安装方式,大家可以参考,如果是Debian系列,可以使用如下命令安装harfbuzz的依赖环境:

  sudo apt-get install libfreetype6-dev libglib2.0-dev libcairo2-dev

- icuuc (ICU C++ library | configure with ICU_LIBS & ICU_INCLUDES or use ICU_LIB_NAME to specify custom lib name  | more info: http://site.icu-project.org/)

  icu4c:http://sourceforge.net/projects/icu/files/ICU4C/55.1/icu4c-55_1-src.zip/download

  version:icu4c-55_1-src.zip

  问题解决:http://stackoverflow.com/questions/18239488/can-not-configure-mapnik-due-to-icuuc
   - boost development headers (more info see: https://github.com/mapnik/mapnik/wiki/Mapnik-Installation & http://www.boost.org)

  boost:官网下载地址

  version:boost_1_60_0.tar.bz2

 

 

 

sudo apt-get install \
    g++ cpp \
    libicu-dev libicu48 \
    python-dev \
    libboost-system-dev \
    libboost-filesystem-dev \
    libboost-iostreams-dev \
    libboost-thread-dev \
    libboost-python-dev \
    libboost-program-options-dev \
    libboost-regex-dev \
    libxml2 libxml2-dev \
    libfreetype6 libfreetype6-dev \
    libjpeg8 libjpeg8-dev \
    libpng12-0 libpng12-dev \
    libtiff5 libtiff5-dev \
    libltdl7 libltdl-dev \
    libproj0 libproj-dev \
    libcairo2 libcairo2-dev python-cairo python-cairo-dev \
    libcairomm-1.0-1 libcairomm-1.0-dev \
    ttf-dejavu ttf-dejavu-core ttf-dejavu-extra ttf-unifont \
    postgresql postgresql-server-dev-9.1 postgresql-contrib \
    libgdal1-dev python-gdal \
    postgresql-9.1-postgis libsqlite3-dev  \
    subversion build-essential python-nose
2.python 测试
关于python的测试,在Mapnik的Github页面的wiki中给出了详细信息,大家可以去详细阅读,我这里只记录一些在测试过程出现问题的详细解决方法(还是前面提到了,最好能FQ,否则就算知道方法,你也下载不到)。
问题1. ImportError: No module named mapnik
    在进行 python -c "import mapnik 步时报出了这个错误,意思就是我们找不到python的mapnik模块。
    其实在说明文档中,已经提示了,在Mapnik 3.x的版本中,Mapnik的python绑定模块不再包含在Mapnik的源代码中,需要另行下载,我们在Github的Mapink板块中可以找到python-mapnik的下载地址。
    Please also note that unlike Mapnik 2.x, version 3.x does not include Python bindings anymore. You can find the new Python bindings here.
    下载下来的python-mapnik需要安装,但是在安装过程中,又出现了问题。
问题2. ImportError: No module named setuptools
    在
python-mapnik的源代码中,我们需要按照README.md文件中的提示,根据自己需求进行安装,但是在执行 python setup.py install 的时候,出现了上述错误。这个错误是说没有setuptools模块,在网上搜索一下就可以知道,这个模块是用来为python安装第三方模块的,其中这篇博客给出了解决办法,但是,不好意思被墙了haha。最后在FQ后的https://pypi.python.org/pypi/setuptools找到了关于setuptools的官方知道,又但是,尽管FQ,还是不能使用官方提供的运行ez_setup.py文件进行安装,因为还是下载不到需要的文件(多么悲伤,想死的心都有了)。下面是python官方的推荐:
    The recommended way to bootstrap setuptools on any system is to download ez_setup.py and run it using the target Python environment. Different operating systems have different recommended techniques to accomplish this basic routine, so below are some examples to get you started(遇到我们的GFW,然并卵).
    但是这个其中页面下面还提供了setuptools的源代码,没办法我只能下载了setuptools-19.6.tar.gz (md5),然后解压后运行进入到源代码文件夹执行:python setup.py install 安装了这个工具(活着不易)。 到此我们终于能运行
python -c "import mapnik;print mapnik.__file__" 成功,并返回了正确的mapnik.py的路径。

相关学习网站:
  https://www.e-education.psu.edu/geog585/node/519

转载于:https://www.cnblogs.com/wanghaiyang1930/p/5146241.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值