close

How to install psycopg2 with pg_config error?

Hello Guys, How are you all? Hope You all Are Fine. Today We Are Going To learn about How to install psycopg2 with pg_config error in Python. So Here I am Explain to you all the possible Methods here.

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

Table of Contents

How to install psycopg2 with pg_config error?

  1. How to install psycopg2 with pg_config error?

    I was getting this issue because I hadn't yet installed PostgreSQL on my machine yet. On mac just a simple brew install postgresql fixed the problem.

  2. install psycopg2 with pg_config error

    I was getting this issue because I hadn't yet installed PostgreSQL on my machine yet. On mac just a simple brew install postgresql fixed the problem.

Method 1

Debian/Ubuntu

Python 2

sudo apt install libpq-dev python-dev

Python 3

sudo apt install libpq-dev python3-dev

Additional

If none of the above solve your issue, try

sudo apt install build-essential
or

sudo apt install postgresql-server-dev-all

With pip

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

pip install psycopg2-binary

Method 2

I was getting this issue because I hadn’t yet installed PostgreSQL on my machine yet. On mac just a simple brew install postgresql fixed the problem.

Summery

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

Also, Read