Install and Update Pip3:
sudo apt install python3-pip sudo pip3 install --upgrade pip sudo pip3 install --upgrade setuptools
Now launch the installation command for psycopg2:
sudo pip3 install psycopg2
If it returns the following error:
Command “python setup.py egg_info” failed with error code 1 in /tmp/pip-build-16pukcwj/psycopg2/
Launch this other command:
sudo apt-get build-dep python3-psycopg2
And then try again with:
sudo pip3 install psycopg2
This method is working perfectly in debian. Thank you!