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)"'.
Running the below on my machine solved the issue:
apt install libpq-dev gcc
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With