brew install libpq --build-from-source
brew install openssl
export LDFLAGS="-L/opt/homebrew/opt/openssl@1.1/lib -L/opt/homebrew/opt/libpq/lib"
export CPPFLAGS="-I/opt/homebrew/opt/openssl@1.1/include -I/opt/homebrew/opt/libpq/include"
pip3 install psycopg2
❯ brew install postgresql
# If you open a new terminal tab you will see that pg_config is available
❯ export CPPFLAGS="-I/opt/homebrew/opt/openssl@1.1/include"
❯ export LDFLAGS="-L/opt/homebrew/opt/openssl@1.1/lib -L${HOME}/.pyenv/versions/3.8.10/lib"
❯ python -V
Python 3.8.10
❯ pip install psycopg2-binary==2.8.6