I\'m trying to install Psycopg2 on my Mac-book. I still get the same error. I found a lot of same questions on Stack Overflow but no answer seems to work. I think it is outd
$ find / -name pg_config 2>/dev/null
/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config
$ export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.3/bin/
$ pip install psycopg2
My issue was that for some reason from within VENV pip install psycopg2 does not work but I found that running this command from inside of VENV
env LDFLAGS='-L/usr/local/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib' pip install psycopg2
allow me to install it on mac.
If you use Docker and you do not want to install postgresql
in you host system,
you can try to use package psycopg2-binary
and use postgresql
in container.
To install psycopg2
you need have installed server before( I have installed PostgresApp)
Run manually command including the path of pg_config
program in PATH
env variable, in my case:
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.4/bin/
and then run
pip3 install psycopg2
EDIT:
Check directory of pg_config
:
which pg_config
On my MAC, this did the trick:
pip install psycopg2-binary
I was fighting with this issue for a complete day. Then I ran a script that I found in Pillow library Issues and solve the problem. Check it out https://github.com/python-pillow/Pillow/issues/3438#issuecomment-435169249