0

I have python application running in docker container based on rhel7-atomic (with python36 installed). I also have separate docker container with PostgreSQL latest version (11.x). I need to install psycopg2 package in application container so it could work with PostgreSQL. But psycopg2 has libpq-dev package as dependency (http://initd.org/psycopg/docs/install.html#build-prerequisites) and I can't install it. As I saw on their page (https://pypi.org/project/libpq-dev/) they have package only available for python with version no more than 3.4 and PostgreSQL version 9.x. Of course, I can try to downgrade both python and PostgreSQL in order to try things to work (which I'm not sure will work). And it seems strange to me that libpq-dev packages are so old. Maybe I am missing something? Another way to successfully install psycopg2 package? I saw solutions for docker containers based on another OS, e.g. Error: pg_config executable not found when installing psycopg2 on Alpine in Docker. But it's not working for me.

Yulia
  • 31
  • 4

2 Answers2

1

In case it may be helpful for others here what worked for my case. I looked through all packages containing pg_config and other stuff I needed for psycopg2 and found out that postgresql-devel would be fine. I tried it out and it worked. (Maybe later I will update answer with more details)

Yulia
  • 31
  • 4
0

You shouldn't need to downgrade Python. I have this working with Ubuntu 18 at the moment. You need to find out what package contains the libpq library on Red Hat. According to this answer, the package you need is postgresql-libs.

FiddleStix
  • 1,253
  • 9
  • 13
  • 2
    I tried to install `postgresql-libs` and it seemed to be successful but `psycopg2` can't find now `pg_config` which should've been installed by `postgresql-libs`. I googled and saw that often `pg_config`'s directory is not added to `PATH`. I tried to find this directory by myself but apparently I can't. Command `find / -name "pg_config"` returns nothing as if there is no such file on server. – Yulia Oct 23 '19 at 20:34