I am having trouble installing psycopg2. I get the following error when I try to pip install psycopg2
:
Error: pg_config executable not found.
P
To those on macOS Catalina using the zsh
shell who have also installed the postgres app:
Open your ~/.zshrc
file, and add the following line:
export PATH="/Applications/Postgres.app/Contents/Versions/latest/bin:$PATH"
Then close all your terminals, reopen them, and you'll have resolved your problem.
If you don't want to close your terminals, simply enter source ~/.zshrc
in whatever terminal you'd like to keep working on.
You need to upgrade your pip before installing psycopg2. Use this command
pip install --upgrade pip
On Mac OS X and If you are using Postgres App (http://postgresapp.com/):
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/latest/bin
No need to specify version of Postgres in this command. It will be always pointed to latest.
and do
pip install psycopg2
P.S: If Changes doesn't reflect you may need to restart the Terminal/Command prompt
Source
Try to add it to PATH:
PATH=$PATH:/usr/pgsql-9.1/bin/ ./pip install psycopg2
Here, for OS X completeness: if you install PostgreSQL from MacPorts, pg_config will be in /opt/local/lib/postgresql94/bin/pg_config
.
When you installed MacPorts, it already added /opt/local/bin
to your PATH.
So, this will fix the problem:
$ sudo ln -s /opt/local/lib/postgresql94/bin/pg_config /opt/local/bin/pg_config
Now pip install psycopg2
will be able to run pg_config
without issues.
On Linux Mint sudo apt-get install libpq-dev
worked for me.