Benja Garrido Benja Garrido - 7 months ago 82
Python Question

Problems using psycopg2 on Mac OS (Yosemite)

Currently i am installing psycopg2 for work within eclipse with python.

I am finding a lot of problems:


  1. The first problem
    sudo pip3.4 install psycopg2
    is not working and it is showing the following message




Error: pg_config executable not found.


FIXED WITH:
export PATH=/Library/PostgreSQL/9.4/bin/:"$PATH”



  1. When I import psycopg2 in my project i obtein:




ImportError:
dlopen(/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/psycopg2/_psycopg.so
Library libssl.1.0.0.dylib
Library libcrypto.1.0.0.dylib


FIXED WITH:
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



  1. Now I am obtaining:




ImportError:
dlopen(/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/psycopg2/_psycopg.so,
2): Symbol not found: _lo_lseek64 Referenced from:
/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/psycopg2/_psycopg.so
Expected in: /usr/lib/libpq.5.dylib in
/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/psycopg2/_psycopg.so


After 3 hours I didn´t find the solution. Can you help me?

Thank you so much!
Regards Benja.

Answer

You need to replace the /usr/lib/libpq.5.dylib library because its version is too old.
Here's my solution to this problem:

$ sudo mv /usr/lib/libpq.5.dylib /usr/lib/libpq.5.dylib.old  
$ sudo ln -s /Library/PostgreSQL/9.4/lib/libpq.5.dylib /usr/lib