Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

django - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

For some reason, the file is missing on the system.

As you're using apt-get, the system is dpkg based, presumably Debian or it's derivative. You can try the Ubuntu's package search to get which package contains a file with name ending in libpq-fe.h.

I found the package is libpq-dev and file's absolute path is /usr/include/postgresql/libpq-fe.h.


FWIW, on a dpkg based system, you can check which package gives a file if you know the file's absolute path:

% dpkg -S /usr/include/postgresql/libpq-fe.h
libpq-dev: /usr/include/postgresql/libpq-fe.h

Also, unlike find, locate keeps a cache of found files (mlocate.db) that is created everyday via cron; so if the file happens to be removed after the last run, you can run locate libfq-fe.h to get the absolute path to the file without needing to check the Ubuntu package search online.


So the package is libpq-dev. Now, reinstalling it will get everything to the default state i.e. all relevant files will be copied to the right places. As it is only a library package, no user/system level configurations will be overridden (and dpkg will prompt you for action for any package that does that).

To reinstall the package:

sudo apt-get install --reinstall libpq-dev

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...