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
bin
directory 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_config
installation withwhich pg_config
orlocate 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 --version
to check its accessibility and installation verification. - Ensure
pg_config
PATH inclusion withexport PATH=/path/to/pg_config:$PATH
. - If
pg_config
is elusive, consider setting the path insetup.cfg
.
Facing common enemies
While dealing with psycopg2, you may encounter:
Python.h
missing errors: Ensure Python development headers installation.libpq-fe.h
nightmares: Check if PostgreSQL headers are part oflibpq-dev
.
Rolling with psycopg2
For psycopg2
installation:
- If you want it quick and easy:
pip install psycopg2-binary
for the pre-compiled binary. - For custom installations:
python setup.py build
thenpython setup.py install
.
Linked
Linked
Was this article helpful?