【问题标题】:Failed to install psycopg2 on mac os在 mac os 上安装 psycopg2 失败
【发布时间】:2019-12-28 07:19:04
【问题描述】:

我将python3.7.2pip 19.2.2 用于python 应用程序。问题是我无法在 MacOS 上安装依赖 psycopg2 2.8.3

下面是我在运行pip 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
  ----------------------------------------
  ERROR: Failed building wheel for psycopg2

似乎ssl没有安装,所以我尝试安装pip install sssl但得到了这个错误:

ERROR: Command errored out with exit status 1:
     command: /Users/joey/.pyenv/versions/3.7.2/bin/python3.7 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/9c/fcm6pxnj39b1t777zpcfpbdh0000gn/T/pip-install-2ldzdiz0/ssl/setup.py'"'"'; __file__='"'"'/private/var/folders/9c/fcm6pxnj39b1t777zpcfpbdh0000gn/T/pip-install-2ldzdiz0/ssl/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info
         cwd: /private/var/folders/9c/fcm6pxnj39b1t777zpcfpbdh0000gn/T/pip-install-2ldzdiz0/ssl/
    Complete output (6 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/9c/fcm6pxnj39b1t777zpcfpbdh0000gn/T/pip-install-2ldzdiz0/ssl/setup.py", line 33
        print 'looking for', f
                          ^
    SyntaxError: Missing parentheses in call to 'print'. Did you mean print('looking for', f)?
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

我不明白为什么它失败了。这是因为版本错误还是与 MacOS 有关?

我已经尝试过这篇文章中提到的方法:How to install psycopg2 with "pip" on Python?。我在 Mac 上安装了 postgressql 并在 PATH 环境中添加了 /usr/local/Cellar/postgresql/11.5/bin/。但这无济于事。

【问题讨论】:

标签: python macos


【解决方案1】:

我认为这个帖子可能会有所帮助error installing psycopg2, library not found for -lssl

clang 是 osx 上的默认 c 编译器,并且是正确构建某些 python 库所必需的。 ssl 错误实际上是 clang 链接器抱怨没有可用的 ssl 库。上面的帖子应该可以解决您的问题。

【讨论】:

  • 是的,这个配置解决了我的问题export LDFLAGS="-L/usr/local/opt/openssl/lib" export CPPFLAGS="-I/usr/local/opt/openssl/include"
【解决方案2】:

我遇到了同样的问题,查看了 Nate 发布的帖子,但在这里找到了我的解决方案:How to update Xcode from command line,由 Roy Huang 发布,他引用了 https://forums.developer.apple.com/thread/104296

事实证明 Mojave 和/或 Xcode 10 没有创建 /usr/include 目录,而 psycopg2 需要能够安装该目录。

【讨论】:

    猜你喜欢
    • 2022-06-29
    • 2012-01-14
    • 2015-07-10
    • 2020-03-31
    • 2017-06-23
    • 2011-04-23
    • 2014-08-01
    • 2021-12-06
    • 1970-01-01
    相关资源
    最近更新 更多