Big picture, the problem is that a required library couldn’t be found. You can alter where psycopg2
looks for libssl
using Apple’s open source compiler tools, otool
and install_name_tool
. These ship with OS X, and manual pages are available with man <command>
.
Change into the psycopg2
module directory mentioned in the error message. Once there:
$ otool -L _psycopg.so
...
@executable_path/../lib/libssl.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
...
This lists the libraries _psycopg2.so
will look for. You can change where it’ll look with install_name_tool
:
$ install_name_tool -change @executable_path/../lib/libssl.1.0.0.dylib /usr/local/opt/openssl/lib/libssl.1.0.0.dylib _psycopg.so
You’ll need to adjust for where you have libssl.1.0.0.dylib
, of course. The example I gave is the default Homebrew path, but you might have it from Anaconda and/or the PostgreSQL app bundle. (brew install openssl
if you don’t have it yet.) You’ll also likely need to repeat for libcrypto.
Executing this change may fail depending on how _psycopg2.so
was built. If that happens, you could probably build the module yourself with custom library paths, but I won’t get into that.
This approach has the advantage of being narrower, and thus less risky, than the approach (given in other answers here) of linking libssl 1.0.0 into dyld
’s search paths (either through ln -s
or setting a DYLD_*
environment variable). (See warnings against these approaches in a pair of discussions and some code. Learn more about dyld
through man dyld
.) It has the disadvantage of needing to be repeated for each copy of psycopg2
. Choose your own adventure.
Disclaimer: Most of the content in this answer is from knowledge I cobbled together in one day. I am no expert.