close

[Solved] ImportError: No module named psycopg2

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error ImportError: No module named 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 ImportError: No module named psycopg2 Error Occurs?

Today I get the following error ImportError: No module named psycopg2 in python.

How To Solve ImportError: No module named psycopg2 Error ?

  1. How To Solve ImportError: No module named psycopg2 Error ?

    To Solve ImportError: No module named psycopg2 Error I faced the same issue and resolved it with following commands:
    sudo apt-get install libpq-dev pip install psycopg2

  2. ImportError: No module named psycopg2

    To Solve ImportError: No module named psycopg2 Error I faced the same issue and resolved it with following commands:
    sudo apt-get install libpq-dev pip install psycopg2

Solution 1

tep 1: Install the dependencies

sudo apt-get install build-dep python-psycopg2

Step 2: Run this command in your virtualenv

pip install psycopg2-binary 

Solution 2

I faced the same issue and resolved it with following commands:

sudo apt-get install libpq-dev
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