python pip install psycopg2 install error

后端 未结 10 1674
余生分开走
余生分开走 2020-11-27 15:31

I did a simple pip install psycopg2 on mac system. It installed fine, but when I try to use psycopg2 I get the error:

Reason: Incompatible libra         


        
相关标签:
10条回答
  • 2020-11-27 15:47

    The accepted answer here is correct (except I think it must be ln -fs , in fact I think it might even risk destabalizing your OS if not (?)). After bumping into this and dealing with it I just want to collect the full solution for this issue and the other lib problem (libcrypto.1.0.0.dylib) you will run into for Postgres 9.* on Mountain Lion and Snow Leopard, and perhaps other systems. This also blocked me from running psql, which complained about the same two libs.

    Essentially there are two later-version libs needed in /usr/lib, libssl and libcrypto. You can find the needed versions of these libs in the Postgres lib directory.

    • If you're OSX and installed the Enterprise DB version of Postgres this will be in /Library/PostgreSQL/9.2/lib.
    • For other install types of Postgres, look for the lib directory inside the Postgress install directory, e.g., for Postgress.app, find the lib directory in /Applications/Postgres.app/Contents/MacOS/lib,
    • for brew somewhere in /usr/local/Cellar,
    • on *nix, wherever your install is. But see first on *nix if your distro has later versions just through the package manager.

    First copy the latest of these two libs from the Postgres lib directory to /usr/lib:

    sudo cp /Library/PostgreSQL/9.2/lib/libssl.1.0.0.dylib /usr/lib
    sudo cp /Library/PostgreSQL/9.2/lib/libcrypto.1.0.0.dylib /usr/lib
    

    Then update (or create) the /usr/lib symlinks for this libs. Either way the command is ln -fs:

    sudo ln -fs /usr/lib/libssl.1.0.0.dylib /usr/lib/libssl.dylib
    sudo ln -fs /usr/lib/libcrypto.1.0.0.dylib /usr/lib/libcrypto.dylib
    

    Should be fixed. Pretty sure ln -fs is better than deleting the symlink and remaking it, so there is less chance of libssl being unfindable by something that needs it for the time it is not present (it does the same thing; it first deletes the symlink if it's already there, just faster than you can type it). Always wary of messing around on /usr/lib.

    0 讨论(0)
  • 2020-11-27 15:47

    If you are uncomfortable copying libraries into your system directory, you can use the DYLD_LIBRARY_PATH environment variable to force the OS to search Postgres's library directory for libssl. E.g.:

    $ DYLD_LIBRARY_PATH=/Library/PostgreSQL/9.4/lib pip install psycopg2
    

    (documented under the dyld man page).

    0 讨论(0)
  • 2020-11-27 15:48

    For me, the libcryto and libss version 1.0.0 resides below:

    /Library/PostgreSQL/9.1/lib/libcrypto.1.0.0.dylib
    /Library/PostgreSQL/9.1/lib/libssl.1.0.0.dylib
    

    so the commands that fix my problem is:

    sudo ln -fs /Library/PostgreSQL/9.1/lib/libssl.1.0.0.dylib /usr/lib/libssl.dylib
    sudo ln -fs /Library/PostgreSQL/9.1/lib/libcrypto.1.0.0.dylib /usr/lib/libcrypto.dylib
    
    0 讨论(0)
  • 2020-11-27 15:52

    When trying to do a syncdb Postgres 9.1 and /psycopg2/_psycopg.so added a further error:

    Library not loaded: @loader_path/../lib/libcrypto.dylib Referenced from: /usr/lib/libpq.5.dylib Reason: Incompatible library version: libpq.5.dylib requires version 1.0.0 or later, but libcrypto.0.9.8.dylib provides version 0.9.8

    Solved by copying these six (6) files from:

    LOCAL:/Library/PostgreSQL/9.1/lib/

    libssl.1.0.0.dylib

    libssl.a

    libssl.dylib

    libcrypto.1.0.0.dylib

    libcrypto.a

    libcrypto.dylib

    to: LOCAL:/usr/lib

    This was on Mac OSx 10.8.1 with a web in a virtualenv (1.8.2) and pgAdmin (1.14.3). Inside the virtualenv is:

    Django==1.4

    psycopg2==2.4.5

    ... etc... and now back to normal.

    0 讨论(0)
  • 2020-11-27 15:54

    For me on Mavericks, it worked to just copy the two dylib and relaunch Python:

    cp /Library/PostgreSQL/9.3/lib/libssl.1.0.0.dylib /usr/lib/
    cp /Library/PostgreSQL/9.3/lib/libcrypto.1.0.0.dylib /usr/lib/
    
    0 讨论(0)
  • 2020-11-27 15:55

    my friend, just copy libssl.* files from PostgreSQL lib directory to /usr/lib and relaunch your application in this case all things will be perfect ^_^

    0 讨论(0)
提交回复
热议问题