For anyone looking for a solution for this on macOS Sierra 10.12: I fixed this by installing command line tools:
xcode-select
After that, pip install psycopg2 should work.
If this is not the case, you can also try setting a link to brew openssl:
env LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib" pip install psycopg2
with openssl installed via brew. Please note that brew link openssl --force no longer works:
$ brew link openssl --force 17.5s Warning: Refusing to link: openssl Linking keg-only openssl means you may end up linking against the insecure, deprecated system OpenSSL while using the headers from Homebrew openssl. Instead, pass the full include/library paths to your compiler eg: -I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib
As @macho points out below, if this still doesn't work, you might have to use the --no-cache option for pip, for example.
env LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib" pip --no-cache install psycopg2
sas Aug 31 '16 at 8:39 2016-08-31 08:39
source share