Problems using psycopg2 on Mac OS (Yosemite)

前端 未结 8 1350
盖世英雄少女心
盖世英雄少女心 2020-12-23 13:49

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 ps
相关标签:
8条回答
  • 2020-12-23 14:09

    For those of you on El Capitan who can't use @KungFuLucky7's answer - I used the following to fix the issue (Adjust paths to match yours where required).

    sudo install_name_tool -change libpq.5.dylib /Library/PostgreSQL/9.5/lib/libpq.5.dylib /usr/local/lib/python2.7/site-packages/psycopg2/_psycopg.so
    
    0 讨论(0)
  • 2020-12-23 14:11

    If you are using PostgresApp, you need to run the following two commands:

    sudo mv /usr/lib/libpq.5.dylib /usr/lib/libpq.5.dylib.old
    sudo ln -s /Applications/Postgres.app/Contents/Versions/9.4/lib/libpq.5.dylib /usr/lib
    
    0 讨论(0)
  • 2020-12-23 14:11

    Here's a fix that worked for me on El Capitan that doesn't require restarting to work around the OS X El Capitan System Integrity Protection (SIP):

    brew unlink postgresql && brew link postgresql
    brew link --overwrite postgresql
    

    H/T Farhan Ahmad

    0 讨论(0)
  • 2020-12-23 14:20

    I am using yosemite, postgres.app & django. this got psycopg2 to load properly for me but the one difference was that my libpq.5.dylib file is in /Applications/Postgres.app/Contents/Versions/9.4/lib.

    thus my second line was sudo ln -s /Applications/Postgres.app/Contents/Versions/9.4/lib/libpq.5.dylib /usr/lib

    0 讨论(0)
  • 2020-12-23 14:21

    I was able to fix this on my Mac (running Catalina, 10.15.3) by using psycopg2-binary rather than psycopg2.

    pip3 uninstall psycopg2 pip3 install psycopg2-binary

    0 讨论(0)
  • 2020-12-23 14:23

    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
    
    0 讨论(0)
提交回复
热议问题