Why psycopg2 is not able to install in a virtual environment?

Just installed ubuntu20.04.

Installed python3.10 by

sudo apt install python3.10

Then created virtualenv

pip install virtualenv
virtualenv -p python3.10 venv

Now I'm trying to install requirement for my project. The only one issue I got was with distutils. But I typed smth like

sudo apt install python3.10-distutils

And it's gone. I have requirements list like

  • amqp==5.0.6
  • asgiref==3.4.1
  • billiard==3.6.4.0
  • celery==5.1.2
  • certifi==2021.5.30
  • charset-normalizer==2.0.6
  • click==7.1.2
  • click-didyoumean==0.0.3
  • click-plugins==1.1.1
  • click-repl==0.2.0
  • dj-database-url==0.5.0
  • Django==3.2.7
  • django-celery-beat==2.2.1
  • django-celery-results==2.2.0
  • django-heroku==0.3.1
  • django-redis==5.0.0
  • django-timezone-field==4.2.1
  • gunicorn==20.1.0
  • idna==3.2
  • kombu==5.1.0
  • prompt-toolkit==3.0.20
  • psycopg2==2.9.1
  • python-crontab==2.5.1
  • python-dateutil==2.8.2
  • python-dotenv==0.19.0
  • pytz==2021.1
  • redis==3.5.3
  • requests==2.26.0
  • six==1.16.0
  • sqlparse==0.4.2
  • urllib3==1.26.6
  • vine==5.0.0
  • wcwidth==0.2.5
  • whitenoise==5.3.0

They all installed except of psycopg2. When I type (in activated virtualenv)

pip install psycopg2==2.9.1

And getting this error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1

4

2 Answers

Try

pip install psycopg2-binary

This will not require any C code compilation

Solved with

sudo apt-get install libpq-dev

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like