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:
i.e in my case, the command with the STEP-3 path is:
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.
1 2 3 | 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:
1 | $ 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:
1 | $ brew install openssl |
STEP-3:
Check the path of openssl lib on your machine. On my machine it was:
1 | $ /usr/local/opt/openssl/lib/ |
STEP-4:
You have to simply include this path from STEP-3 by running following command:
1 | $ export DYLD_LIBRARY_PATH=***YOUR OPENSSL PATH FROM STEP-3 HERE*** |
1 | $ 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:
1 2 | $ 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.