简体   繁体   English

在 mac os 上安装 psycopg2 失败

[英]Failed to install psycopg2 on mac os

I am using python3.7.2 and pip 19.2.2 for a python application.我正在将python3.7.2pip 19.2.2用于 python 应用程序。 The problem is that I can't install the dependency psycopg2 2.8.3 on MacOS.问题是我无法在 MacOS 上安装依赖项psycopg2 2.8.3

Below is the error I got on running pip install psycopg2 :以下是我在运行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

It seems that ssl is not installed so I tried to install pip install sssl but got this error:似乎没有安装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.

I don't understand why it failed.我不明白为什么它失败了。 Is this because of a wrong version or relates to MacOS?这是因为版本错误还是与 MacOS 有关?

I have tried the method mentioned in this post: How to install psycopg2 with "pip" on Python?我已经尝试了这篇文章中提到的方法: How to install psycopg2 with "pip" on Python? . . I installed postgressql on the Mac and added /usr/local/Cellar/postgresql/11.5/bin/ on PATH env.我在 Mac 上安装了postgressql并在 PATH env 上添加了/usr/local/Cellar/postgresql/11.5/bin/ But it doesn't help.但它没有帮助。

I think this thread may be of help error installing psycopg2, library not found for -lssl我认为这个线程可能有助于安装 psycopg2,找不到 -lssl 的库

clang is the default c compiler on osx, and is required for some python libraries to be built correctly. clang 是 osx 上的默认 c 编译器,并且是正确构建某些 python 库所必需的。 The ssl error is actually the clang linker complaining that there is no ssl library available to be used. ssl 错误实际上是 clang 链接器抱怨没有可用的 ssl 库。 The above thread should resolve your issue.上面的线程应该可以解决您的问题。

I had the same issue, and looked at the thread posted by Nate, but found my solution here: How to update Xcode from command line , posted by Roy Huang, who referenced https://forums.developer.apple.com/thread/104296我遇到了同样的问题,并查看了 Nate 发布的线程,但在这里找到了我的解决方案: How to update Xcode from command line ,由 Roy Huang 发布,他引用了https://forums.developer.apple.com/thread/ 104296

It turns out Mojave and/or Xcode 10 does not create a /usr/include directory, which psycopg2 needs to be able to install.事实证明,Mojave 和/或 Xcode 10 没有创建 /usr/include 目录,psycopg2 需要能够安装该目录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM