Reputation: 2388
I am installing psycopg2 into a python venv through poetry poetry add psycopg2
but i get the below error.
I have tried to use older versions of psycopg2. Does anyone know why this problem occurs and how to properly fix it?
Following other questions on Stackoverflow I tried to install psycopg2-binary which is installed properly but later, that gives different issues when trying to apply django migrations.
Note: This error originates from the build backend, and is likely not a problem with poetry but with psycopg2 (2.9.9) not supporting PEP 517 builds. You can verify this by running 'pip wheel --use-pep517 "psycopg2 (==2.9.9)"'.
Upvotes: 7
Views: 7934
Reputation: 537
The error is most likely caused by missing libraries needed to compile psycopg2. It is recommended to use the pre-compiled binary through the wheel available at PyPI with pip install psycopg2-binary
. This should be faster to install and is more likely to work than installing psycoog2 from source.
Upvotes: 3
Reputation: 2388
Running the below on my machine solved the issue:
apt install libpq-dev gcc
Upvotes: 9