Psycopg2 image not found

后端 未结 20 1540
无人及你
无人及你 2020-11-29 18:04

Trying to setup postgres with the postgres mac app and hit this error, which I haven\'t been able to solve. Any thoughts?

    ImportError: dlopen(/Users/Crai         


        
相关标签:
20条回答
  • 2020-11-29 18:17
    pip install psycopg2-binary
    

    works like a charm!

    Discussion on source+wheel distribution (pyscopg2) vs a separate binary distribution (psycopg2-binary): https://www.postgresql.org/message-id/CA%2Bmi_8bd6kJHLTGkuyHSnqcgDrJ1uHgQWvXCKQFD3tPQBUa2Bw%40mail.gmail.com

    Explanation on the decision to release psycopg2-binary: http://initd.org/psycopg/articles/2018/02/08/psycopg-274-released/

    However, there are reports of psycopg2-binary not satisfying psycopg2 dependencies. More discussion here: https://github.com/psycopg/psycopg2/issues/674

    0 讨论(0)
  • 2020-11-29 18:21

    Just wanted to share what worked for me. I was using Anaconda with jupyter. The following did work:

     DYLD_LIBRARY_PATH=/usr/local/Cellar/openssl/1.0.2k/lib  jupyter notebook
    

    But then caused later issues importing another library (plotly). After playing around with pip, I realised I should probably be using conda instead and the following seemed to fix everything.

    conda install psycopg2
    
    0 讨论(0)
  • 2020-11-29 18:24

    In case if you are working on python/django with virtual environment

    Worked for me for the following Version

    • MacOS Catalina 10.5.2
    • python 3.7.3
    • Django 3.0.2
    • psycopg2==2.8.4
    • virtualenv 16.6.0
    • pip 19.3.1
    • postgres (PostgreSQL) 11.2

    3 Steps Solutions

    • Delete Existing Virtual Environment
    • Create New Virtual Environemnt again
    • Install Dependencies again
    0 讨论(0)
  • 2020-11-29 18:27

    I had the same error because of upgrading Postgres.app (from 9.3 to 9.4).

    The solution was to delete the pip cache wheels because they were pointing to Postgres.app version 9.3.

    I've found the according psycopg wheel cache files this way

    grep -r psycopg ~/.pip/cache
    

    and deleted the directory I've found with the last command.

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

    This problem cost me the whole morning to solve. I found the discussion on http://initd.org/psycopg/articles/2010/11/11/links-about-building-psycopg-mac-os-x/ really helpful. Thanks to Jurie's answer, the solution to my problem (in Mac) is as below:

    1. Install openssl 1.0.0 using brew:

       brew install openssl
      
    2. using the following command:

      export DYLD_LIBRARY_PATH=/usr/local/Cellar/openssl/**1.0.1x**/lib
      

      replace 1.0.1x part with your current version. For me it is 1.0.1h.

    Hope this helps!

    EDIT: After one day, I found that the second command has to be entered every time when needing to connect to database, so not a permanent solution to this problem.

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

    I encountered this issue when I upgraded from postgres.app 9.4 to 9.5 on el capitan.

    The other solutions will not work (easily) in el capitan because of the system lock on certain directories, meaning the symbolic link solution will be less accessible/ideal for most.

    This leaves the fallback variable. The current answer points to the wrong directory. I am guessing the dylibs directory has changed since 2013.

    So, here is the latest fallback directory that works for me:

    export DYLD_FALLBACK_LIBRARY_PATH=/Applications/Postgres.app/Contents/Versions/latest/lib:$DYLD_LIBRARY_PATH
    
    0 讨论(0)
提交回复
热议问题