'How to install libpq-fe.h?

I cannot figure this out for the life of me.

When I pip install django-tenant-schemas it tries to install the dependency psycopg2 which requires the Python headers and gcc. I have all this installed and still keep getting this error!

./psycopg/psycopg.h:35:10: fatal error: libpq-fe.h: No such file or directory

So to install libpq-fe-h I need to sudo apt-get install libpq-dev..

..which returns..

libpq-dev is already the newest version (10.10-0ubuntu0.18.04.1).

Then when I sudo find / libpq-fe.h it doesn't seem to be in my OS.

I am lost at this point. If anyone can help I would highly appreciate it.



Solution 1:[1]

Well after installing these libraries sudo dnf install python-virtualenv openssl-devel gcc libffi-devel libxslt-devel issue was not gone.

I used mlocate to find where libpq-fe.h file is located. On my system (Fedora 32) it was located at /usr/pgsql-10/include/libpq-fe.h

yum install mlocate
sudo updateb
locate libpq-fe.h

After all added this line to ~/.bash_profile

nano ~/.bash_profile
export PATH=/usr/pgsql-10/bin/:$PATH

Works fine, I can easily install psycopg2 without any trouble.

Solution 2:[2]

You need to create a LD_LIBRARY_PATH that indicates the path of your library /user/pgsql-11/lib

Source: The 3rd point of build prerequisites at https://www.psycopg.org/docs/install.html#build-prerequisites

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 vinzee
Solution 2 vinzee