Skip to content

Instantly share code, notes, and snippets.

@hanleybrand
Last active January 13, 2021 20:39
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hanleybrand/8611994 to your computer and use it in GitHub Desktop.
Save hanleybrand/8611994 to your computer and use it in GitHub Desktop.
Install imposm on a mac with all dependencies in a vm, with postgress.app for postgis

Installing imposm

So, according to the imposm docs:

Imposm runs with Python 2.5, 2.6 and 2.7 and is tested on Linux and Mac OS X. Other dependencies are:

psycopg2: PostgreSQL adapter for Python

Tokyo Cabinet: File-based key-value database for the internal cache

Google Protobuf: PBF parsing library

GEOS Geospatial geometries library

Some parts are written as a C extension and so you need to have a C/C++ compiler and the Python header files.

Imposm also requires the following Python packages:

imposm.parser: XML and PBF parsing sub-package

Shapely: Python bindings for GEOS. 1.2 or newer is required, >=1.2.10 is recommended.

But while it's great that it's "tested on ... Mac OS X" unfortunately all of the installation instructions are for Ubuntu. So here's how to do it on a Mac:

Set up a virtual environment

virtualenv ~/.virtualenvs/gis
source ~/.virtualenvs/gis/bin/activate

Everything below should be installed with the gis virtualenv activated

psycopg2

installing psycopg2 [needs psql in your $PATH and an ARCHFLAGS correction] (http://alirazabhayani.blogspot.com/2013/07/install-psycopg2-on-mac-os-x-pgconfig.html) assuming you installed postgress.app -- otherwise sub your path to psql check the path with:

which psql

if not found, put your postgress bin dir in your path. The path below is what it will be if you installed psql via postgresapp

export PATH=/Applications/Postgres93.app/Contents/MacOS/bin:$PATH
sudo env ARCHFLAGS="-arch i386 -arch x86_64"
pip install psycopg2

GEOS

Thank goodness for homebrew

brew install geos

Protobuf

brew install protobuf

Other python stuff

pip install imposm.parser
pip install Shapely

Tokyo Police Club Cabinet

mkdir tokyocabinet
cd tokyocabinet
wget http://fallabs.com/tokyocabinet/tokyocabinet-1.4.48.tar.gz
tar xvf tokyocabinet-1.4.48.tar.gz 
cd tokyocabinet-1.4.48
./configure 
make
sudo make install

Imposm

pip install imposm
@chadlagore
Copy link

chadlagore commented Mar 12, 2017

Thank you this works perfectly for me 👏

@twairball
Copy link

I get errors finding protobuf headers when installing pip install imposm.parser and imposm:

In file included from imposm/parser/pbf/osm.cc:6:
    imposm/parser/pbf/osm.pb.h:9:10: fatal error: 'google/protobuf/stubs/common.h' file not found
    #include <google/protobuf/stubs/common.h>
             ^
    1 error generated.
    error: command 'gcc' failed with exit status 1

What version of protobuf do I need to downgrade to?

@otreidel
Copy link

I'm getting an error installing imposm.parser.

In file included from imposm/parser/pbf/osm.cc:6:
In file included from imposm/parser/pbf/osm.pb.h:23:
In file included from /usr/local/include/google/protobuf/arena.h:54:
/usr/local/include/google/protobuf/arena_impl.h:182:10: error: thread-local storage is not supported for the current target
static GOOGLE_THREAD_LOCAL ThreadCache thread_cache_;
^
/usr/local/include/google/protobuf/stubs/port.h:354:29: note: expanded from macro 'GOOGLE_THREAD_LOCAL'
#define GOOGLE_THREAD_LOCAL __thread
^
1 error generated.
error: command '/usr/bin/clang' failed with exit status 1

Any ideas?

@TimMcCauley
Copy link

TimMcCauley commented Feb 17, 2018

For those with missing header files - if you are running Ubuntu or any other UNIX dist, please try to install protobuf from source, this will provide the necessary header files, for instance arena.h, common.h, etc.

Instructions: https://github.com/google/protobuf/blob/master/src/README.md

If you are using OS X brew install protobuf should do the job.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment