pythoncondamapnik

How to install mapnik python3 wrapper in conda?


I have installed mapnik 3.0.12 with conda install -c mrterry mapnik, but why I can`t import it in my code?

import mapnik

ModuleNotFoundError: No module named 'mapnik'

I looked in anaconda3/pkgs/mapnik-3.0.12-0/lib and there is no python3.7 folder there, only .so and .a files.

I have installed mapnik with sudo apt install python3-mapnik in ubuntu 18.04 and it imports well with /usr/bin/python3 interpreter. And in directory /usr/lib/python3/dist-packages/mapnik there is some .py files.


Solution

  • I'm not familiar with the tool, but it looks like Mapnik is a C++ library that has separate Python bindings. You need to install both mapnik and python-mapnik. Only Python 2 is supported, so you need to create a new env for this.

    Conda (only if you trust the channel)

    A search of Anaconda Cloud shows only linux-64 platform is available and only from user channels. I'm following your lead on using the mrterry channel, but generally I will only use a channel if I trust the user/org.

    conda create -n myenv -c mrterry python=2.7 mapnik python-mapnik
    

    Recommended Approach

    Since I don't recognize any of the channels in the search, personally I would just follow the official install instructions. First, I would set up a Conda env with Python 2.7 and the dependencies that Mapnik lists. Then activate that env, and proceed with following the instructions (./configure, make, etc.).