Using OpenSSL 1.1 with pip

If you are using PostgreSQL or MySQL on a Mac, you might have run into this error when installing libraries via pip.

ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'clang' failed with exit status 1

It seems like this started happening in relation to a homebrew upgrade, where the version of libssl was changed from 1.0 to 1.1.

The fix is pretty simple, set LDFLAGS so that pip can locate the missing library.

LDFLAGS="-L/usr/local/opt/openssl@1.1/lib" pip install -r requirements.txt

And the installation should succeed