Search code examples
psycopg2python-venvpython-poetry

Problem installing psycopg2 for Python venv through poetry


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)"'.


Solution

  • Running the below on my machine solved the issue:

    apt install libpq-dev gcc