Error: No module named psycopg2.extensions

Solution 1:

The first thing to do is to install the dependencies.

sudo apt-get build-dep python-psycopg2
sudo apt install python3-psycopg2 # Python 3

After that go inside your virtualenv and use:

pip install psycopg2-binary

These two commands should solve the problem.

Solution 2:

pip install psycopg2-binary

The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: http://initd.org/psycopg/docs/install.html#binary-install-from-pypi.

Solution 3:

For Django 2 and python 3 install psycopg2 using pip3 :

pip3 install psycopg2

Solution 4:

For macOS Mojave just run pip install psycopg2-binary. Works fine for me, python version -> Python 3.7.2