Import psycopg2 Library not loaded: libssl.1.0.0.dylib

前端 未结 20 2421
囚心锁ツ
囚心锁ツ 2020-11-28 21:02

When I try to run the command:

import psycopg2

I get the error:

ImportError: dlopen(/Users/gwulfs/anaconda/lib/python2.7/si         


        
相关标签:
20条回答
  • 2020-11-28 21:34

    Do the following to resolve Library not loaded:libssl.1.0.0.dylib error if you have openssl in /usr/local/Cellar directory

    1. sudo cp /usr/local/Cellar/openssl/<<version>>/lib/libssl.1.0.0.dylib /usr/lib

    2. After doing step 1, if you still get Library not loaded:libcrypto.1.0.0.dylib error. Do the following
          sudo cp /usr/local/Cellar/openssl/<<version>>/lib/libcrypto.1.0.0.dylib /usr/lib

    0 讨论(0)
  • 2020-11-28 21:37

    I had to vary Scott Brennstuhl's answer a little: 1. Remove broken symlinks:

    $ sudo rm /usr/lib/libssl.1.0.0.dylib
    $ sudo rm /usr/lib/libcrypto.1.0.0.dylib
    $ sudo rm /usr/lib/libpq.5.dylib
    
    1. Relink with postgres' included drivers:
    $ sudo ln -s   /Applications/Postgres.app/Contents/Versions/9.4/lib/libssl.1.0.0.dylib /usr/lib    
    $ sudo ln -s /Applications/Postgres.app/Contents/Versions/9.4/lib/libcrypto.1.0.0.dylib /usr/lib
    $ sudo ln -s /Applications/Postgres.app/Contents/Versions/9.4/lib/libpq.5.dylib  /usr/lib
    
    0 讨论(0)
  • 2020-11-28 21:37

    I tried pip install psycopg2 which was giving similar issues. Then I tried conda install psycopg2, which worked! Also make sure the pip you are using belongs to anaconda (which pip)

    0 讨论(0)
  • 2020-11-28 21:39

    EDIT: potentially dangerous, read comments first!

    See a much safer answer below: https://stackoverflow.com/a/30726895/308315


    I ran into this exact issue about an hour after you posted it and just figured it out. I am using Mac OS X Yosemite, Python 2.7, and the Postgresql app.

    There seems to be a non-working symlink set by default (or I introduced it while troubleshooting), to fix it first remove the incorrect links:

    $ sudo rm /usr/lib/libssl.1.0.0.dylib
    $ sudo rm /usr/lib/libcrypto.1.0.0.dylib
    

    Then re-link them with (replace YOURUSERNAME with your Mac user name. I found it helpful to use tab to complete each step, to confirm the directory):

    $ sudo ln -s /Users/YOURUSERNAME/anaconda/lib/libssl.1.0.0.dylib /usr/lib
    $ sudo ln -s /Users/YOURUSERNAME/anaconda/lib/libcrypto.1.0.0.dylib /usr/lib
    

    I believe the other solutions didn't work for you because your version is in anaconda.

    0 讨论(0)
  • 2020-11-28 21:39

    I was having this issue on Mac, trying ln -s was giving me ln: /usr/lib/libssl.1.0.0.dylib: Operation not permitted I didn't want to mess with my system. Instead What worked for me is to simply install psycopg2-binary : pip install psycopg2-binary

    This installed psycopg2-binary-2.8.3 version

    0 讨论(0)
  • 2020-11-28 21:39

    So first for me openssl re-install never worked. It was quite irritating that all of the above answers failed for me. To be sure that it's a openssl issue, first, install psycopg2-binary using pip

      pip install psycopg2-binary
    

    After installing psycopg2-binary, if you're getting error like ld: library not found for -lssl then do the following

      export LDFLAGS="-L/usr/local/opt/openssl/lib"
      export CPPFLAGS="-I/usr/local/opt/openssl/include"
    

    if these didn't work then you can try to upgrade psycopg2 and re-check that issue still there or not.

      pip install psycopg2 --upgrade
    

    if all the above didn't worked then only try reinstalling openssl as mentioned in all above answers.

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