Failed building wheel for psycopg2

My mistake:
Command "/ Users/qinlan/myproject/lenv1/bin/python3.6 - u - c" import setuptools, tokenize; __file__='/private/var/folders/l1/y1ch9__s6xx00p046b096_6m0000gn/T/pip-install-_p50tkoi/psycopg2/setup.py'; f=getattr(tokenize, 'open', open)(__file__); code=f.read().replace('\r\n', '\n'); f.close(); exec(compile(code, __file__, 'exec'))" install --record /private/var/folders/l1/y1ch9__s6xx00p046b096_6m0000gn/T/pip-record-jml81n0v/install-record.txt --single-version-externally-managed --compile --install-headers /Users/qinlan/myproject/lenv1/bin/../include/site/python3.6 psycopg2 "failed with the error code 1 in/private/var/folders/l1/y1ch9__s6xx00p046b096_6m0000gn/T/PIP - install - _p50tkoi/psycopg2/
Fix:
I fixed this problem by installing the command line tool
xcode-select --install
then install openssl through Homebrew and manually link the openssl installed by my homemade software to PIP:
env LDFLAGS = "-i/usr/local/opt/openssl/include - L/usr/local/opt/openssl/lib" PIP install psycopg2
in the macOS Sierra 10.12.1
It is recommended that PIP Install PsycopG2-Binary instead

Read More: