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.