I encountered following error on my MacOS X after installing PostgreSQL and Psycopg2 for my Python and Django based application.
STEP-1:
Check if you have openssl installed by writing openssl on the commandline:
If it starts, this means its installed in your system and you may skip STEP-2 and go directly to STEP-3.
STEP-2:
If openssl isn't installed, install it by:
STEP-3:
Check the path of openssl lib on your machine. On my machine it was:
STEP-4:
You have to simply include this path from STEP-3 by running following command:
You may also have to create a symbolic link to PostgreSQL's lib folder. For that, first check your path of PostgreSQL's lib folder and then write following commands accordingly:
Now run python/ Django shell and import psycopg2. I had no errors after following this recipe.
ImportError: dlopen(/Users/aliraza/Projects/VirtualEnv/django1.5/lib/python2.7/site-packages/psycopg2/_psycopg.so, 2): Library not loaded: libssl.1.0.0.dylib Referenced from: /Users/aliraza/Projects/VirtualEnv/django1.5/lib/python2.7/site-packages/psycopg2/_psycopg.so Reason: image not found
STEP-1:
Check if you have openssl installed by writing openssl on the commandline:
$ openssl
If it starts, this means its installed in your system and you may skip STEP-2 and go directly to STEP-3.
STEP-2:
If openssl isn't installed, install it by:
$ brew install openssl
STEP-3:
Check the path of openssl lib on your machine. On my machine it was:
$ /usr/local/opt/openssl/lib/
STEP-4:
You have to simply include this path from STEP-3 by running following command:
$ export DYLD_LIBRARY_PATH=***YOUR OPENSSL PATH FROM STEP-3 HERE***i.e in my case, the command with the STEP-3 path is:
$ sudo export DYLD_LIBRARY_PATH=/usr/local/opt/openssl/lib/
You may also have to create a symbolic link to PostgreSQL's lib folder. For that, first check your path of PostgreSQL's lib folder and then write following commands accordingly:
$ sudo ln -s /Library/PostgreSQL/9.4/lib/libssl.1.0.0.dylib /usr/lib/ $ sudo ln -s /Library/PostgreSQL/9.4/lib/libcrypto.1.0.0.dylib /usr/lib/
Now run python/ Django shell and import psycopg2. I had no errors after following this recipe.