Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application

People also ask

What is PostgreSQL server Dev?

The postgresql-server-dev-all package provides the pg_buildext script for simplifying packaging of a PostgreSQL extension supporting multiple major versions of the product. PostgreSQL is a fully featured object-relational database management system.

What is Libpq Dev?

From Postgres' documentation, libpq is the C application programmer's interface to PostgreSQL. libpq is a set of library functions that allow client programs to pass queries to the PostgreSQL backend server and to receive the results of these queries.


Use these following commands, this will solve the error:

sudo apt-get install postgresql

then fire:

sudo apt-get install python-psycopg2

and last:

sudo apt-get install libpq-dev

I just run this command as a root from terminal and problem is solved,

sudo apt-get install -y postgis postgresql-9.3-postgis-2.1
pip install psycopg2

or

sudo apt-get install libpq-dev python-dev
pip install psycopg2

Just install libpq-dev

$ sudo apt-get install libpq-dev

For me this simple command solved the problem:

sudo apt-get install postgresql postgresql-contrib libpq-dev python-dev

Then I can do:

 pip install psycopg2

For Python 3, I did:

sudo apt install python3-dev postgresql postgresql-contrib python3-psycopg2 libpq-dev

and then I was able to do:

pip3 install psycopg2