3

I have been searching the web hours on end for several days and I am unable to install psycopg2 library on my Linux machine (CentOS - 2.6.32-431.3.1.el6.x86_64 GNU/Linux).

I know that the problem is that I am missing the libpq header files since I am getting this message after attempting pip install psycopg2: libpq-fe.h: No such file or directory

http://initd.org/psycopg/docs/install.html#install-from-source

Almost all the articles I found pointed me to use apt-get on CentOS but apt-get is not a standard tool on CentOS 6.3 so I've been trying yum install instead.

However, every time I try to use sudo yum install to download something the package is not available. For example:

yum install postgresql-devel Loaded plugins: fastestmirror, refresh-packagekit, security Setting up Install Process Loading mirror speeds from cached hostfile drivesrvr | 2.2 kB 00:00 No package postgresql-devel available. Error: Nothing to do

I've tried this for:

  1. yum install postgresql-server
  2. yum install python-devel
  3. service postgresql initdb
  4. service postgresql start
  5. yum install python-psycopg2

Any ideas? Without the the libpq header files I can't install the psycopg2 module that is necessary for my Python program. This is for Python 2.7.12. And PostgreSQL 9.3.13.

Andrew Goss
  • 45
  • 1
  • 6

1 Answers1

9

I had this exact issue on Fedora 2016.09 box on Amazon. I was able to install postgresql-devel via yum, but that didn't do the trick; the version seemed to be out of date.

I solved it using:

sudo yum install /usr/include/libpq-fe.h

This installs an updated version of postgresql-devel which allows psycopg2 to compile correctly when installing through pip.

ataki
  • 101
  • 1
  • 6