Pg_config executable not found
⚡TLDR
To quickly resolve the pg_config not found error, install the libpq-dev package with the command appropriate for your system:
- Ubuntu:
sudo apt install libpq-dev - Fedora:
sudo dnf install postgresql-devel - Mac:
brew install postgresql - Windows: Add PostgreSQL's
bindirectory to your PATH.
The pg_config will be installed, and your operations can proceed error-free.
Troubleshooting: extra steps
If you've installed libpq-dev and still face issues, consider:
- Verifying the
pg_configinstallation withwhich pg_configorlocate pg_config. - If you're using a virtual environment, try reinstalling psycopg2.
- Ensure a C compiler like GCC is installed, as psycopg2 requires compilation.
- For resolving virtualenv-specific issues, consider the
[Psycopg2 Virtualenv Installation](http://web.archive.org/web/20140615091953/http://goshawknest.wordpress.com/2011/02/16/how-to-install-psycopg2-under-virtualenv/)guide.
Post-install inspection checklist
Once the package is installed:
- Use
pg_config --versionto check its accessibility and installation verification. - Ensure
pg_configPATH inclusion withexport PATH=/path/to/pg_config:$PATH. - If
pg_configis elusive, consider setting the path insetup.cfg.
Facing common enemies
While dealing with psycopg2, you may encounter:
Python.hmissing errors: Ensure Python development headers installation.libpq-fe.hnightmares: Check if PostgreSQL headers are part oflibpq-dev.
Rolling with psycopg2
For psycopg2 installation:
- If you want it quick and easy:
pip install psycopg2-binaryfor the pre-compiled binary. - For custom installations:
python setup.py buildthenpython setup.py install.
Linked
Linked
Was this article helpful?