When I try to run the command:
import psycopg2
I get the error:
ImportError: dlopen(/Users/gwulfs/anaconda/lib/python2.7/site-packages/psycopg2/_psycopg.so, 2): Library not loaded: libssl.1.0.0.dylib
Referenced from: /Users/gwulfs/anaconda/lib/python2.7/site-packages/psycopg2/_psycopg.so
Reason: image not found
So far I have tried brew install openssl
and have referenced (with no luck):
psycopg2 installation error - Library not loaded: libssl.dylib
http://joshuakehn.com/2013/10/13/Postgresapp-and-psycopg2-on-OS-X.html
Psycopg2 image not found
The psycopg2-binary package is meant for beginners to start playing with Python and PostgreSQL without the need to meet the build requirements. If you are the maintainer of a published package depending on psycopg2 you shouldn't use psycopg2-binary as a module dependency.
psycopg2-binary and psycopg2 both give us the same code that we interact with. The difference between the two is in how that code is installed in our computer.
Instead of playing with symlinks in system library dirs, set the $DYLD_FALLBACK_LIBRARY_PATH
to include the anaconda libraries. eg:
export DYLD_FALLBACK_LIBRARY_PATH=$HOME/anaconda/lib/:$DYLD_FALLBACK_LIBRARY_PATH
After Homebrew wouldn't allow me to force link openssl
the following worked fine:
pip install --global-option=build_ext \
--global-option="-I/usr/local/opt/openssl/include" \
--global-option="-L/usr/local/opt/openssl/lib" psycopg2
(this installation succeeded in a virtualenv
on macOS)
EDIT: potentially dangerous, read comments first!
See a much safer answer below: https://stackoverflow.com/a/30726895/308315
I ran into this exact issue about an hour after you posted it and just figured it out. I am using Mac OS X Yosemite, Python 2.7, and the Postgresql app.
There seems to be a non-working symlink set by default (or I introduced it while troubleshooting), to fix it first remove the incorrect links:
$ sudo rm /usr/lib/libssl.1.0.0.dylib
$ sudo rm /usr/lib/libcrypto.1.0.0.dylib
Then re-link them with (replace YOURUSERNAME with your Mac user name. I found it helpful to use tab to complete each step, to confirm the directory):
$ sudo ln -s /Users/YOURUSERNAME/anaconda/lib/libssl.1.0.0.dylib /usr/lib
$ sudo ln -s /Users/YOURUSERNAME/anaconda/lib/libcrypto.1.0.0.dylib /usr/lib
I believe the other solutions didn't work for you because your version is in anaconda.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With