In an attempt to install psycopg2 via pip, you encountered an error indicating the absence of the pg_config executable. To resolve this issue, you can choose one of the following options:
Install the pre-compiled binary wheel of psycopg2, which avoids the need to build the package from source. For this, execute:
pip install psycopg2-binary
Ensure you have the prerequisites for building the psycopg2 package:
Debian/Ubuntu:
Python Version | Command | Note |
---|---|---|
Default Python 3 | sudo apt install libpq-dev python3-dev | |
Python 3.x | sudo apt install libpq-dev python3.x-dev | Replace "x" with the desired Python version |
Python 2 | sudo apt install libpq-dev python-dev |
After installing the prerequisites, build the package with the following command:
python setup.py build_ext --pg-config /path/to/pg_config build ...
Replace "/path/to/pg_config" with the actual path to the pg_config executable.
The above is the detailed content of How to Resolve \'pg_config\' Executable Issue for psycopg2 Installation in Python?. For more information, please follow other related articles on the PHP Chinese website!