yuv
yuv

Reputation: 594

Cannot install "psycopg2" on Windows 10 with Python 3.8

Yesterday I uninstalled python 3.7 version by mistake. Then I install python again (this time 3.8 version) and again set up my environment. But I could not start my Django project which has Postgres connection. Actually I cannot install "psycopg2" in my environment. I searched for hours and implement every solutions I get from online but it does not work. Let me tell you what I did so far.



Please help me to get rid of this. I stuck for hours.

Upvotes: 12

Views: 21604

Answers (4)

fran
fran

Reputation: 1

On a Windows10, python3.8, conda environment, the following solved my problem:

pip install --upgrade wheel

pip install --upgrade setuptools

pip install psycopg2==2.8.4

Upvotes: 0

Sourav Mondal
Sourav Mondal

Reputation: 21

This problem mainly occurs due to this -- " error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/"

Now to install psycopg2, first you need to install visual studio from Microsoft - https://visualstudio.microsoft.com/visual-cpp-build-tools/ now you need to install the c++ desktop development tool with all its default components selected.

After successful visual studio c++ desktop development kit installation, you can now install psycopg2 successfully in your machine.

Upvotes: 0

Devanshu
Devanshu

Reputation: 49

use:

sudo apt install python3-dev libpq-dev

then try doing:

pip3 install psycopg2

Hope it works for you!!

Upvotes: 2

Alasdair
Alasdair

Reputation: 308779

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.

Upvotes: 16

Related Questions