Skip to content
This repository

Installing Mapnik on Ubuntu

For all versions of Ubuntu it is a good idea to be fully up to date before starting:

sudo apt-get update
sudo apt-get upgrade

For older versions, see the archived notes at UbuntuInstallationOld

If you are intending to install Tilemill from a package/ppa, do not follow the directions below in order to avoid package conflicts. Instead, directly proceed to install Tilemill. Mapnik will automatically be installed with your Tilemill installation because it is available in the TileMill PPA.


Ubuntu >= (11.10)

Install from packages

First, ensure add-apt-repository is installed:

sudo apt-get install -y python-software-properties

Mapnik v2.2.0

This is the latest in the 2.2.x series.

sudo add-apt-repository ppa:mapnik/v2.2.0
sudo apt-get update
sudo apt-get install libmapnik libmapnik-dev mapnik-utils python-mapnik

These packages come from: https://launchpad.net/~mapnik/+archive/v2.2.0/+packages

Mapnik v2.3.x

This is the nightly build of the upcoming 2.3.0 release

sudo add-apt-repository ppa:mapnik/nightly-2.3
sudo apt-get update
sudo apt-get install libmapnik libmapnik-dev mapnik-utils python-mapnik
# also install datasource plugins if you need them
sudo apt-get install mapnik-input-plugin-gdal mapnik-input-plugin-ogr\
  mapnik-input-plugin-postgis \
  mapnik-input-plugin-sqlite \
  mapnik-input-plugin-osm

These packages come from: https://launchpad.net/~mapnik/+archive/nightly-2.3/+packages

For nightly builds from master (3.0.0-pre)

This is the latest development code - built nightly - directly from https://github.com/mapnik/mapnik/commits/master

sudo add-apt-repository ppa:mapnik/nightly-trunk
sudo apt-get update
sudo apt-get install libmapnik libmapnik-dev mapnik-utils python-mapnik
sudo apt-get install mapnik-input-plugin-gdal mapnik-input-plugin-ogr\
  mapnik-input-plugin-postgis \
  mapnik-input-plugin-sqlite \
  mapnik-input-plugin-osm

These packages come from: https://launchpad.net/~mapnik/+archive/nightly-trunk/+packages

Install Mapnik from source

First, remove any other old mapnik packages:

sudo apt-get purge libmapnik* mapnik-utils python-mapnik

Ensure your boost version is recent enough (at least 1.47)

Mapnik master may require a boost version more recent than provided by your Ubuntu distribution.

Ubuntu 12.04 Precise ships with 2 different boost versions: 1.46 and 1.48. Make sure you install the correct version (see below) or use the latest Boost version (that works with Mapnik) by installing Boost from the mapnik/boost PPA:

sudo add-apt-repository ppa:mapnik/boost
sudo apt-get update
sudo apt-get install libboost-dev libboost-filesystem-dev libboost-program-options-dev libboost-python-dev libboost-regex-dev libboost-system-dev libboost-thread-dev 

Note: You can see the boost version offered by your distro with the below command. And if you are using the above PPA then its version should show up as a candidate for installation:

apt-cache policy libboost-dev

Set up build environment

    # On Ubuntu 12.04 Precise, make sure you get the 1.48 boost packages:
    sudo apt-get install \
    libboost-filesystem1.48-dev \
    libboost-program-options1.48-dev \
    libboost-python1.48-dev libboost-regex1.48-dev \
    libboost-system1.48-dev libboost-thread1.48-dev

    # On newer system or if you've activated the mapnik PPA, then use this:
    sudo apt-get install \
    libboost-filesystem-dev \
    libboost-program-options-dev \
    libboost-python-dev libboost-regex-dev \
    libboost-system-dev libboost-thread-dev \

    # get a build environment going...
    sudo apt-get install \
    libicu-dev \
    python-dev libxml2 libxml2-dev \
    libfreetype6 libfreetype6-dev \
    libjpeg-dev \
    libltdl7 libltdl-dev \
    libpng-dev \
    libproj-dev \
    libtiff-dev \
    libcairo2 libcairo2-dev python-cairo python-cairo-dev \
    libcairomm-1.0-1 libcairomm-1.0-dev \
    ttf-unifont ttf-dejavu ttf-dejavu-core ttf-dejavu-extra \
    git build-essential python-nose clang \
    libgdal1-dev python-gdal \
    postgresql-9.1 postgresql-server-dev-9.1 postgresql-contrib-9.1 postgresql-9.1-postgis \
    libsqlite3-dev

Source install of Mapnik 2.3.x

# For the development branch:
git clone https://github.com/mapnik/mapnik mapnik-2.3.x -b 2.3.x
cd mapnik-2.3.x
./configure && make && sudo make install

Source install of Mapnik Master (3.x)

First download, compile and install harfbuzz

wget http://www.freedesktop.org/software/harfbuzz/release/harfbuzz-0.9.26.tar.bz2
tar xf harfbuzz-0.9.26.tar.bz2
cd harfbuzz-0.9.26
./configure && make && sudo make install
sudo ldconfig
cd ../

Then upgrade your compiler to at least g++ 4.7 so it supports c++11 features and then build mapnik:

sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test;
sudo apt-get update -y
sudo apt-get install -y gcc-4.7 g++-4.7;
export CXX="g++-4.7" && export CC="gcc-4.7";
git clone https://github.com/mapnik/mapnik
cd mapnik
./configure CXX=${CXX} CC=${CC}
make && sudo make install

Testing

To test mapnik:

make test
Something went wrong with that request. Please try again.