Aaron Lelevier
Aaron Lelevier

Reputation: 20838

PostgreSQL with OSX Mavericks and Psycopg2 not able to connect with Django Localhost on Mac

I am currently running:

Postgresql 9.3.1
psycopg2==2.5.2
OSX Mavericks 10.9.2
Python 2.7.6
Django 1.5.4

I am trying to launch my Django App to test, but am getting a configuration error with psycopg2. This is the error. It was working before upgrading the OSX to Mavericks, and now I can't get it to work. Any ideas on how to fix this?

ImportError: dlopen(/Users/Yuki_Aaron/Documents/virtualenvs/flapsta2/lib/python2.7/site-packages/psycopg2/_psycopg.so, 2): Library not loaded: libpq.5.dylib
  Referenced from: /Users/Yuki_Aaron/Documents/virtualenvs/flapsta2/lib/python2.7/site-packages/psycopg2/_psycopg.so
  Reason: no suitable image found.  Did find:
    /usr/local/lib/libpq.5.dylib: mach-o, but wrong architecture
    /usr/lib/libpq.5.dylib: mach-o, but wrong architecture

Upvotes: 1

Views: 1672

Answers (1)

Aaron Lelevier
Aaron Lelevier

Reputation: 20838

To get this working I had to symlink the most recent libpq.5.dylib file from my PostgreSQL directory to my /usr/lib/libqp.5.dylib file, and PostgreSQL and Psycopg2 finally work!

@serakiel, thank you for your suggestion, that helped lead to the answer.

Here is the command that I ran in Terminal to fix the issue:

sudo ln -fs /library/postgresql/9.3/lib/libpq.5.6.dylib /usr/lib/libpq.5.dylib

Upvotes: 3

Related Questions