Error loading psycopg2 module when installed from a 'wheel'

旧时模样 提交于 2019-12-24 05:14:12

问题


I am trying to install some python requirements from a local package directory containing wheel archives. I am installing the requirements inside a Docker container.

The steps I'm following are:

$ 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 the requirements are installed correctly:

# 'app' is the name of my built docker image
$ docker run app pip list
...
psycopg2 (2.5.1)
...

However, if I actually try running something inside the container that uses psycopg2, then I get the following:

Error loading psycopg2 module: /usr/local/lib/python2.7/site-packages/psycopg2/_psycopg.so: undefined symbol: PyUnicodeUCS4_AsUTF8String

I presume that this is something to do with the way in which the wheels were built - I ran pip wheel on the container host machine (Ubuntu 12.04).

How can I fix this - using wheels significantly reduces the time taken to build the container image, so I don't want to revert to installing packages if I can help it?


回答1:


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




回答2:


In my experience, psycopg2 can be rather finicky when installing/building from source, so am not surprised that it doesn't package into a wheel. However, could you simply wheel everything apart from psycopg2? Still would save you a heap of time.



来源:https://stackoverflow.com/questions/22450848/error-loading-psycopg2-module-when-installed-from-a-wheel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!