1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
[](https://travis-ci.org/mapnik/python-mapnik)
Python bindings for Mapnik.
## Installation
Eventually we hope that many people will simply be able to `pip install mapnik` in order to get prebuilt binaries,
this currently does not work though. So for now here are the instructions
### Create a virtual environment
It is highly suggested that you [a python virtualenv](http://docs.python-guide.org/en/latest/dev/virtualenvs/) when developing
on mapnik.
### Building from Mason
If you do not have mapnik built from source and simply wish to develop from the latest version in [mapnik master branch](https://github.com/mapnik/mapnik) you can setup your environment with a mason build. In order to trigger a mason build prior to building you must set the `MASON_BUILD` environment variable.
```bash
export MASON_BUILD=true
```
After this is done simply follow the directions as per a source build.
### Building from Source
Assuming that you built your own mapnik from source, and you have run `make install`. Set any compiler or linking environment variables as necessary so that your installation of mapnik is found. Next simply run one of the two methods:
```
python setup.py develop
```
If you are currently developing on mapnik-python and wish to change the code in place and immediately have python changes reflected in your environment.
```
python setup.py install
```
If you wish to just install the package.
```
python setup.py develop --uninstall
```
Will de-activate the development install by removing the `python-mapnik` entry from `site-packages/easy-install.pth`.
If you need Pycairo, make sure that PYCAIRO is set to true in your environment or run:
```
PYCAIRO=true python setup.py develop
```
## Testing
Once you have installed you can test the package by running:
```
git submodule update --init
python setup.py test
```
The test data in `./test/data` and `./test/data-visual` are standalone modules. If you need to update them see https://github.com/mapnik/mapnik/blob/master/docs/contributing.markdown#testing
### Troubleshooting
If you hit an error like:
```
Fatal Python error: PyThreadState_Get: no current thread
Abort trap: 6
```
That means you likely have built python-mapnik is linked against a differ python version than what you are running. To solve this try running:
```
/usr/bin/python <your script.py>
```
If you still hit a problem create an issue and we'll try to help.
|