I failed to install psycopg2 in Python virtual environment, I am using Ubuntu 18.04 for its installation. The following error is shown below:
After googling I found the following solution below:
under virtual environment, install:
pip install wheel
or
pip install --upgrade wheel
Deactivate the virtual environment using command deactivate, then:
For Python 2
sudo apt install libpq-dev python-dev
For Python 3
sudo apt install libpq-dev python3-dev
If none of the above solve your issue, try
sudo apt install build-essential
or
sudo apt install postgresql-server-dev-all
Credit: https://stackoverflow.com/questions/5420789/how-to-install-psycopg2-with-pip-on-python
Then install psycopg2 after activating the Python virtual environment:
pip install psycopg2
After googling I found the following solution below:
under virtual environment, install:
pip install wheel
or
pip install --upgrade wheel
Deactivate the virtual environment using command deactivate, then:
For Python 2
sudo apt install libpq-dev python-dev
For Python 3
sudo apt install libpq-dev python3-dev
If none of the above solve your issue, try
sudo apt install build-essential
or
sudo apt install postgresql-server-dev-all
Credit: https://stackoverflow.com/questions/5420789/how-to-install-psycopg2-with-pip-on-python
Then install psycopg2 after activating the Python virtual environment:
pip install psycopg2