【问题标题】:How to install Python SSL module on OSX?如何在 OSX 上安装 Python SSL 模块?
【发布时间】:2010-06-20 06:19:15
【问题描述】:

当我部署我的谷歌应用引擎项目时,我收到以下警告:

WARNING appengine_rpc.py:399 ssl module not found.
Without the ssl module, the identity of the remote host cannot be verified, and
connections may NOT be secure. To fix this, please install the ssl module from
http://pypi.python.org/pypi/ssl.

我下载了包,但是当我尝试时

python setup.py build

我得到以下错误输出:

looking for /usr/include/openssl/ssl.h
looking for /usr/local/ssl/include/openssl/ssl.h
looking for /usr/contrib/ssl/include/openssl/ssl.h
Traceback (most recent call last):
  File "setup.py", line 167, in <module>
    ssl_incs, ssl_libs, libs = find_ssl()
  File "setup.py", line 142, in find_ssl
    raise Exception("No SSL support found")
Exception: No SSL support found

我需要做什么来安装它,是路径问题还是什么?

【问题讨论】:

  • 如警告所示,您没有安装 SSL 模块。您是否有理由怀疑有人想要 MitM 您与 App Engine 服务器的连接?

标签: python google-app-engine ssl


【解决方案1】:

通过首先安装 pycrypto,按照 here 的说明并使用对 this question 的答案的见解进行修复。

我用于最终构建的完整命令行是:

CC='/usr/bin/gcc-4.0' python2.5 setup.py build

【讨论】:

  • 谢谢。您的命令行只是帮助我使用 google 说明为 python 编译 ssl。我还必须重新安装 XCode,我设法放弃了 OS 10.4 的 SDK,因为我没有意识到我会再次需要它。这是希望。
【解决方案2】:

10.5 和 10.6 上的库存 Apple python 包括 ssl 模块(不清楚早期版本):

Python 2.6.5 (r265:79359, Mar 24 2010, 01:32:55) 
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
>>> ssl.__file__
'/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ssl.pyc'

(从 10.5.8 开始)

即使您有 ssl,您实际上也可以从 appengine_rpc.py 获得该错误消息 - 您需要确保您的 GAE 下载具有:

/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/cacerts/cacerts.txt

如果你同时具备这两个条件,请尝试这样做:

import google.appengine.tools.https_wrapper

这应该适用于现有的 Apple python,但如果不适用,错误消息可能会提供更多信息。如果您安装了多个 python,其中一个搞砸了 GAE,请确保使用 GAE 中的 Python 路径首选项指向 Apple Python。

【讨论】:

  • GAE使用python 2.5,而不是系统默认安装的python 2.6。
【解决方案3】:

您可能需要手动安装 openssl,尽管默认 Xcode 安装时应将头文件放在 /usr/include 中。 (如果您还没有安装 Xcode,那么您的机器上不太可能有 gcc,并且无论如何构建都会在此过程的后期失败。)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-07
    • 1970-01-01
    • 2012-01-19
    • 2016-09-22
    • 2021-10-04
    相关资源
    最近更新 更多