Problems using psycopg2 on Mac OS (Yosemite)

Benja Garrido picture Benja Garrido · Feb 14, 2015 · Viewed 16.3k times · Source

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

Can you help me?

Answer

KungFuLucky7 picture KungFuLucky7 · Feb 20, 2015

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