Can't install psycopg2 with pip in virtualenv on Mac OS X 10.7 Can't install psycopg2 with pip in virtualenv on Mac OS X 10.7 python python

Can't install psycopg2 with pip in virtualenv on Mac OS X 10.7


Just would like to share. The following code worked for me:

env LDFLAGS='-L/usr/local/lib -L/usr/local/opt/openssl/lib-L/usr/local/opt/readline/lib' pip install psycopg2==2.5.2

I am using macOS Sierra and psql 9.6.1.

I got the lib path from the pg_config command.


I am using MAC OS CATALINA verison 10.15.5 with python3 and psql (PostgreSQL) 12.3. Here is what worked for me:

Try installing openssl using brew

brew install openssl

after that export these variables in the terminal.

export LDFLAGS="-L/usr/local/opt/openssl/lib"export CPPFLAGS="-I/usr/local/opt/openssl/include"

verify these variables have been exported by echo $LDFLAGS and after that you are good to go with installation of psycopg2 by typing

pip3 install psycopg2


First, download Postgres.app.

Then, before running pip install psycopg2, put the binary in your path:

export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.3/bin

NOTICE:

9.3 stands for version and will differ over time.