Trouble With Psycopg2 In Virtualenv Python3 For Use With Django
Solution 1:
To resolve this issue I installed Python3-dev as Leonardo suggested. I was trying to use the python 2 dev tools which obviously didn't work.
Solution 2:
I fixed this issue using the package "aiopg" which internally installs psycopg2.This package is specially designed for async operations in postgres, but will solve your purpose aswell
pip install aiopg
Solution 3:
I too was facing this problem while trying to run a Django project with PostgreSQL database running in a virtual environment on Ubuntu 18.04 which was configured under the Windows WSL subsystem.
As suggested in other answers, I too was installing everything for Python2 unknowingly, later I just installed all the required tools for Python3 and it worked.
I ran the following commands:
sudo apt install postgresql postgresql-contrib
sudo apt install libpq-dev
sudo apt install python3-dev
sudo apt install python3-pip
sudo apt install python3-psycopg2
pip3 install psycopg2
pip3 install psycopg2-binary
Plus, also check if the Ubuntu and Python and Psycopg versions are compatible together.
Post a Comment for "Trouble With Psycopg2 In Virtualenv Python3 For Use With Django"