It appears you are missing some prerequisite to build the package from source.
You may install a binary package by installing ‘psycopg2-binary’ from PyPI.
If you want to install psycopg2 from source, please install the packages
required for the build and try again.
For further information please check the ‘doc/src/install.rst’ file (also at
https://www.psycopg.org/docs/install.html).
error: command ‘/usr/bin/x86_64-linux-gnu-gcc’ failed with exit code 1
at ~/.local/lib/python3.10/site-packages/poetry/installation/chef.py:164 in _prepare
160│
161│ error = ChefBuildError(“nn”.join(message_parts))
162│
163│ if error is not None:
→ 164│ raise error from None
165│
166│ return path
167│
168│ def _prepare_sdist(self, archive: Path, destination: Path | None = None) -> Path:
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 –no-cache-dir –use-pep517 “psycopg2 (==2.9.9)”‘.
I am working on a flask project, so i am trying to configure my database using sqlalchemy with postgres. I am using poetry as a virtualenv for my project. I am trying to install the psycopg2 using poetry add psycopg2 but it’s giving me the error, even though the postgress container is up in the background.