When using Python with virtualenv, you may encounter installation issues with psycopg2. This guide addresses the specific error message "pg_config executable not found" and provides two options for resolving the problem.
For Linux and Mac users, an easier solution is to install the psycopg2-binary package, which provides pre-built wheels:
pip install psycopg2-binary
If you prefer to install psycopg2 from source, ensure that the necessary prerequisites are installed:
Python Version | Command |
---|---|
Default Python 3 | sudo apt install libpq-dev python3-dev |
Python 3.x | sudo apt install libpq-dev python3.x-dev |
Python 2 | sudo apt install libpq-dev python-dev |
After installing the prerequisites, you can proceed with building psycopg2 from source. For further instructions, refer to the psycopg2 documentation.
The above is the detailed content of How to Resolve \'pg_config executable not found\' Error When Installing psycopg2 for Python in Virtualenv?. For more information, please follow other related articles on the PHP Chinese website!