我正在使用 Docker 和psycopg2来连接我的 docker-compose 中的另一个数据库服务。但是,我收到 psycopg2 的导入错误:
Python 3.8.2 (default, Feb 29 2020, 17:03:31)
[GCC 9.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import psycopg2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.8/site-packages/psycopg2/__init__.py", line 50, in <module>
from psycopg2._psycopg import ( # noqa
ImportError: Error relocating /usr/lib/python3.8/site-packages/psycopg2/_psycopg.cpython-38-x86_64-linux-gnu.so: SSL_check_private_key: symbol not found
这是我尝试使用psycopg2的 Dockerfile:
FROM osgeo/gdal:alpine-normal-latest
ENV PYTHONUNBUFFERED 1
RUN apk update && apk add \
--virtual build-deps gcc python-dev musl-dev \
postgresql-dev \
libpq \
python3-dev \
curl \
libffi-dev
ADD . /app
WORKDIR /app
COPY requirements.txt requirements.txt
RUN pip3 install --no-cache-dir -r requirements.txt
CMD ["sh", "./entry.sh"]