Import psycopg2 Library not loaded: libssl.1.0.0.dylib

前端 未结 20 2419
囚心锁ツ
囚心锁ツ 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:29

    Instead of playing with symlinks in system library dirs, set the $DYLD_FALLBACK_LIBRARY_PATH to include the anaconda libraries. eg:

    export DYLD_FALLBACK_LIBRARY_PATH=$HOME/anaconda/lib/:$DYLD_FALLBACK_LIBRARY_PATH
    
    0 讨论(0)
  • 2020-11-28 21:29

    I am using Mac OS Sierra: and got this error:

     Library not loaded: libssl.1.1.dylib
    

    I found this library in

     /Library/PostgreSQL/11/lib
    

    I found this solution in internet:

     export DYLD_LIBRARY_PATH=/Library/PostgreSQL/11/lib
    

    But this is not a permanent solution. As I have to run the above command whenever I restart my server.

    Add the line: export DYLD_LIBRARY_PATH=/Library/PostgreSQL//lib
    to ~/.bash_profile

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

    The solution that worked for me (https://stackoverflow.com/a/30726895 did not) was installing psycopg2-binary with: pip install psycopg2-binary==2.7.6

    This is on MacOS Mohave.

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

    I encountered this problem after running brew upgrade, which updated openssl from 1.0.0 to 1.1.1. That causes the error in the question because I'm using pyscopg 2.7.4, which is pinned to openssl@1.0. More recent versions of psycopg (>2.8) are pinned to openssl@1.1.

    So your options in this situation are to upgrade your psycopg version to 2.8.1 or later (in your Pipfile/Pipfile.lock, etc.), or force brew to keep using openssl@1.0 with this command, taken from https://github.com/Homebrew/homebrew-core/issues/47348#issuecomment-560001981:

    brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/64555220bfbf4a25598523c2e4d3a232560eaad7/Formula/openssl.rb -f
    
    0 讨论(0)
  • 2020-11-28 21:31

    brew reinstall openssl postgres did the trick for me

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

    conda install psycopg works for me. It updates the following packages The following packages will be UPDATED:

    conda:      3.19.1-py27_0 --> 4.0.5-py27_0
    openssl:    1.0.2f-0      --> 1.0.2g-0
    pip:        8.0.2-py27_0  --> 8.1.0-py27_0
    setuptools: 19.6.2-py27_0 --> 20.2.2-py27_0
    wheel:      0.26.0-py27_1 --> 0.29.0-py27_0
    
    0 讨论(0)
提交回复
热议问题