Cannot install "psycopg2" on Windows 10 with Python 3.8

use:

sudo apt install python3-dev libpq-dev

then try doing:

pip3 install psycopg2

Hope it works for you!!


When you asked this question, Python 3.8 had been released very recently so there were not any wheels for Python 3.8 yet.

At the time, my suggestion was to install Python 3.7.X and install the binary wheel with:

pip install psycopg2-binary

Since then, binary wheels have been released for Python 3.8, so the above command should work with Python 3.8.X as well.

I wouldn't try to build from source on Windows if it can be avoided.

Finally, you misunderstood the section of the docs about Python 2. You only need Python 2.7 if you are running Python 2. For Python 3, which you should be using for all new projects, it currently supports Python 3.4 to 3.8.