Psycopg2 installation

The short version

First install the prerequisites (not needed on Windows, please adapt to your *nix distribution):

sudo apt install python3-dev libpq-dev

Then install the module:

pip install psycopg2

The complete version

For all the details, please check the installation docs.