Error loading psycopg2 module when installing from "wheel"
I'm trying to install some python requirements from a local package directory containing wheel archives. I am setting requirements inside a Docker container.
The following steps are listed below:
$ pip install wheel
# wheel runs, outputs .whl files to wheelhouse directory
$ pip wheel --wheel-dir wheelhouse -r requirements.txt
Then inside my Dockerfile
:
ADD requirements.txt /tmp/requirements.txt
ADD wheelhouse /tmp/wheelhouse
# install requirements. Leave file in /tmp for now - may be useful.
RUN pip install --use-wheel --no-index --find-link /tmp/wheelhouse/ -r /tmp/requirements.txt
This works - and all requirements are set correctly:
# 'app' is the name of my built docker image
$ docker run app pip list
...
psycopg2 (2.5.1)
...
However, if I actually try to run something inside the container uses psycopg2
, I get this:
Error loading psycopg2 module: /usr/local/lib/python2.7/site-packages/psycopg2/_psycopg.so: undefined symbol: PyUnicodeUCS4_AsUTF8String
I suppose it has to do with how the wheels were built - I ran pip wheel
on a container machine (Ubuntu 12.04).
How can I fix this - using wheels greatly reduces the time it takes to collect the container image, so I don't want to go back to installing packages if I can help it?
source to share