close

[Solved] Unable to install psycopg2 (pip install psycopg2)

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Unable to install psycopg2 (pip install psycopg2) in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Unable to install psycopg2 (pip install psycopg2) Error Occurs?

Today I get the following error Unable to install psycopg2 (pip install psycopg2) in python.

How To Solve Unable to install psycopg2 (pip install psycopg2) Error ?

  1. How To Solve Unable to install psycopg2 (pip install psycopg2) Error ?

    To Solve Unable to install psycopg2 (pip install psycopg2) Error On Mac Mavericks with Postgres.app version 9.3.2.0 RC2 I needed to use the following code after installing Postgres:

  2. Unable to install psycopg2 (pip install psycopg2)

    To Solve Unable to install psycopg2 (pip install psycopg2) Error On Mac Mavericks with Postgres.app version 9.3.2.0 RC2 I needed to use the following code after installing Postgres:

Solution 1


Note
: Since a while back, there are binary wheels for Windows in PyPI, so this should no longer be an issue for Windows users. Below are solutions for Linux, Mac users, since lots of them find this post through web searches.


Option 1

Install the psycopg2-binary PyPI package instead, it has Python wheels for Linux and Mac OS.

pip install psycopg2-binary

Option 2

Install the prerequsisites for building the psycopg2 package from source:

Debian/Ubuntu

Python 3

sudo apt install libpq-dev python3-dev

You might need to install python3.8-dev or similar for e.g. Python 3.8.

Python 21

sudo apt install libpq-dev python-dev

If that’s not enough, try

sudo apt install build-essential

or

sudo apt install postgresql-server-dev-all

as well before installing psycopg2 again.

CentOS 6

Solution 2

On Mac Mavericks with Postgres.app version 9.3.2.0 RC2 I needed to use the following code after installing Postgres:

sudo PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.3/bin pip install psycopg2

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read