Because my Lenovo X1 Carbon died this week (what the hell – non working adaptive keyboard, ghost screen effect and finally damaged mother-board !!!), I have to work with iMac a few days because there was no other Win pc in the office (And it is very painful and hard task if you want to be productive).
Mono is working correctly, Python is working correctly, but as on Windows, psycopg2 is NOT working correctly after installation and there must be done additional steps to make it working.
Note: PostgreSql must be installed. In this tutorial I have installed last version 9.4.
Possible problems:
- First when I tried pip install psycopg2, there was following error:
Error: pg_config executable not found.
Solution: activate virtualenv you want to use and run following command. It adds path to PostgreSql bin folder where is situated pg_config file.
PATH=$PATH:/Library/PostgreSQL/9.4/bin/
- When I run project where was psycopg2 imported, I got:
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/psycopg2/_psycopg.so Library libssl.1.0.0.dylib Library libcrypto.1.0.0.dylib
Solution: run following commands to create symlinks to needed libs. If the symlinks already exist, remove them first (or rename them to have backup).
# first make backup sudo mv /usr/lib/libssl.1.0.0.dylib /usr/lib/libssl.1.0.0.dylib.old sudo mv /usr/lib/libcrypto.1.0.0.dylib /usr/lib/libcrypto.1.0.0.dylib.old # create new symlinks sudo ln -s /Library/PostgreSQL/9.4/lib/libssl.1.0.0.dylib /usr/lib/libssl.1.0.0.dylib sudo ln -s /Library/PostgreSQL/9.4/lib/libcrypto.1.0.0.dylib /usr/lib/libcrypto.1.0.0.dylib
- Then I run the app again and obtained:
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/psycopg2/_psycopg.so, 2): Symbol not found: _lo_lseek64 Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/psycopg2/_psycopg.so Expected in: /usr/lib/libpq.5.dylib in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/psycopg2/_psycopg.so
Solution: Run following commands to backup actual symlink and make correct one.
# first make backup sudo mv /usr/lib/libpq.5.dylib /usr/lib/libpq.5.dylib.old # create new symlinks sudo ln -s /Library/PostgreSQL/9.4/lib/libpq.5.dylib /usr/lib
And now, it should work correctly!