psycopg2 installation error - Library not loaded: libssl.dylib
Does the error say libssl.dylib
version is too old?
On my mac, the error is that libssl.dylib
and libcrypto.dylib
is too old for pyscopg to use. The openssl
package used by mac is 0.98, while pyscopg needs 1.0.0 or later version.
My solution is this:
-
install openssl from brew
$ brew install openssl
-
copy
libssl.1.0.0.dylib
andlibcrypto.1.0.0.dylib
from/usr/local/Cellar/openssl/1.0.1c
to/usr/lib/
$ cd /usr/local/Cellar/openssl/1.0.1c/lib $ sudo cp libssl.1.0.0.dylib libcrypto.1.0.0.dylib /usr/lib/
-
in
/usr/lib
directory, make a softlinklibssl.dylib
andlibcrypto.dylib
. You may have to remove the existing links.$ sudo rm libssl.dylib libcrypto.dylib $ sudo ln -s libssl.1.0.0.dylib libssl.dylib $ sudo ln -s libcrypto.1.0.0.dylib libcrypto.dylib
I think in Mac we need:
export LDFLAGS="-L/usr/local/opt/openssl/lib"
On OSX 10.11+ (El Capitan or later) solution with replacing symlinks (see above - https://stackoverflow.com/a/11911870/565525) sudo rm libssl.dylib libcrypto.dylib
reports Operation not permitted
. Solution that worked for me was:
brew install openssl
Find where openssl brew libs are located, start searching from directory /usr/local/Cellar/openssl
. In my case it is in /usr/local/Cellar/openssl/1.0.2d_1/lib
Finally set up DYLD_LIBRARY_PATH, i.e. add a line like this into .bash_profile :
# replace location of lib files with folder name you found in previous step
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/usr/local/Cellar/openssl/1.0.2d_1/lib
restart shell, or just source ~/.bash_profile
and test if it works:
$ python -c"import psycopg2 ; print('psycopg2 is now ok')"