I am using Docker along with psycopg2 to connect with another database service in my docker-compose. However, I get an import error with 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
Here is my Dockerfile I am trying to use psycopg2 with:
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"]
It seems as though there was an issue with the docker image I was using. I ended up using thinkwhere/gdal-python:3.7-shippable
and I am able to import psycopg2 without any issues.