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?

+2


source to share


2 answers


I don't know what wheel or docker is, but your error comes from a mismatch between the Python used to build the module and the one trying to run it.



+4


source


In my experience, psycopg2 can be quite thin when installed / built from source, so I shouldn't be surprised that it doesn't pack in a wheel. However, could you just bypass everything except psycopg2? It will save you a lot of time anyway.



+1


source







All Articles