I\'m attempting to make a website with a few others for the first time, and have run into a weird error when trying to use Django/Python/VirtualEnv. I\'ve found solutions to
If you aren't used to installing Python C-extensions, and psycopg2 isn't a core part of your work, try
pip install psycopg2-binary
psycopg2 is a C-extension, so it requires compilation when being installed by pip. The Build Prerequisites section of the docs explain what must be done to make installation via pip possible. In summary (for psycopg 2.8.5):
libpq header files must be installedpg_config program must be installed (it usually comes with the libpq headers) and on $PATH. With these prerequisites satisfied, pip install psycopg2 ought to succeed.
Alternatively, pip can install pre-compiled binaries so that compilation (and the associated setup) is not required. They can be installed like this:
pip install psycopg2-binary
The docs note that
The psycopg2-binary package is meant for beginners to start playing with Python and PostgreSQL without the need to meet the build requirements.
but I would suggest that psycopg2-binary is often good enough for local development work if you are not using psycopg2 directly, but just as a dependency.
Read the informative installation documentation, not only to overcome installation issues but also the impact of using the pre-compiled binaries in some scenarios.