ModuleNotFoundError: No module named 'psycopg2' in ipython

Viewed 2540

This question has been asked before but none of the answers are unsatisfactory condition. I am trying to set up a PostgreSQL database for pandas with jupyter notebook (ipython) always I have following error ModuleNotFoundError: No module named 'psycopg2' the same I have connect with my Django project its working fine.

for this I have Installed following packages even I facing same issue. I am using ubuntu 18.04 bionic verion.

sudo apt-get install python3-psycopg2
pip3 install psycopg2-binary

enter image description here

3 Answers

Finally I have a solution for this. I just installed following package and its made my postgres connection.

conda install psycopg2

Maybe you installed psycopg2 in ubuntu's default python and you are trying notebook in anaconda's environment. First try installing jupyter-notebook in virtualenv where psycopg2 works for django. If it works there then its an issue of different environment.

in the notebook cell, execute:

!pip install psycopg2-binary
Related