【问题标题】:How to use pip3 install psycopg2?如何使用 pip3 安装 psycopg2?
【发布时间】:2020-02-12 12:48:46
【问题描述】:

我在 Mac 上运行“pip3 install psycopg2”时遇到了这个错误。

我想第一次安装 psycopg2。

...
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for psycopg2
Running setup.py clean for psycopg2
Failed to build psycopg2
Installing collected packages: psycopg2
Running setup.py install for psycopg2 ... error
ERROR: Command errored out with exit status 1:
...

我试过 pip,从 GitHub 安装。然而,两者都失败了。

有人可以帮帮我吗?我真的很感激!

【问题讨论】:

标签: python macos pip installation psycopg2


【解决方案1】:

只需将psycopg2 版本升级到 2.7.6 即可与python3 一起正常工作:

pip3 install psycopg2==2.7.6

【讨论】:

    【解决方案2】:

    通过浏览这些对我的帖子发表评论的很棒的人分享的上述链接,我终于得到了工作。

    brew upgrade postgresql
    sudo pip install psycopg2
    

    感谢大家的帮助!

    【讨论】:

      【解决方案3】:

      安装:打开终端(编辑器或本地)

      $ brew install postgresql
      $ brew services start postgresql
      

      然后转到 sql 提示创建数据库(不要离开终端):

      $ psql postgres
      

      CREATE DATABASE .. CREATE USER GRANT ...

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-01-28
        • 2020-04-12
        • 1970-01-01
        • 2019-10-10
        • 2021-02-20
        • 1970-01-01
        • 1970-01-01
        • 2020-07-17
        相关资源
        最近更新 更多