Can't install psycopg2 package through pip install… Is this because of Sierra?

后端 未结 13 848
逝去的感伤
逝去的感伤 2020-11-28 01:35

I am working on a project for one of my lectures and I need to download the package psycopg2 in order to work with the postgresql database in use. Unfortunately, when I try

相关标签:
13条回答
  • 2020-11-28 02:25

    In case you don't want to faff around with brew, here's the "MacOS-only solution":

    sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
    

    After this, pip will gladly install psycopg2 from the source. Works with "Mojave" (macOS 10.14).

    0 讨论(0)
  • 2020-11-28 02:27

    Old, but for folks using pipenv, I resolved this issue by looking at my dependency graph pipenv graph --reverse and noticing it required psycopg2-binary==2.8.2. Running pipenv install psycopg2-binary resolved the issue.

    0 讨论(0)
  • 2020-11-28 02:28

    Running into a similar problem using pipenv install psycopg2:

    ld: library not found for -lssl', ' clang: error: linker command failed with exit code 1 (use -v to see invocation)', " error: command 'clang' failed with exit status 1", '
    ----------------------------------------',

    I tried all of the recommendations above and none of them worked. I'd faced this problem in another virtualenv a few months ago and remembered reading something about this being a psycopg2 version issue. So I tried installing with 2.7.1 and 2.8.3 and both still failed. Somehow version 2.7.7 worked:

    pipenv install psycopg2==2.7.7
    

    Wish I had time to look into this further to understand what's really happening. But for now I don't and this worked.

    0 讨论(0)
  • 2020-11-28 02:29

    try this -->pip install psycopg2-binary

    0 讨论(0)
  • 2020-11-28 02:31
    1. Install/update Xcode developer tools

      xcode-select --install
      
    2. Query postgres path

      find / -name pg_config  2>/dev/null
      
    3. Install psycopg2, use the path you got in step 2. Mine was '/usr/local/Cellar/postgresql/9.5.0/bin/pg_config'

      PATH=$PATH:/usr/local/Cellar/postgresql/9.5.0/bin/ pip install psycopg2
      
    0 讨论(0)
  • 2020-11-28 02:32
    brew install postgresql
    

    If postgresql exist then run:

    brew upgrade postgresql
    sudo pip install psycopg2
    

    In venv:

    env LDFLAGS='-L/usr/local/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib' pip install psycopg2==2.8.4
    

    If you need use only the command pip install psycopg2 export the path in macOSX:

    export LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib"
    
    0 讨论(0)
提交回复
热议问题