What it means
Most Python packages come as a ready-made file called a wheel. When no wheel fits your Python version and system, pip tries to compile the package from source, and that needs compilers and system libraries. Here the compile failed. The package named in the message is the one that failed.
How to fix it
-
Use a version with a prebuilt wheel
For Postgres, use
psycopg2-binary, orpsycopg[binary], instead ofpsycopg2. The binary versions include what they need. -
Pin a Python version that has wheels
Packages publish wheels for new Python releases some time after they ship. Pin an older version in
.python-version, for example3.12, and deploy again. -
If it needs system libraries, use a Dockerfile
Some packages need a system library that the standard build image does not have. A Dockerfile can install it. See how to deploy with your own Dockerfile.
psycopg[binary]