如何在OSX上安装Python SSL模块?

时间:2010-06-20 06:19:16

标签: python google-app-engine ssl

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

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

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

3 个答案:

答案 0 :(得分:5)

首先安装pycrypto,然后按照here的说明并使用this question答案中的见解来修复。

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

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

答案 1 :(得分: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一起使用,但如果没有,错误消息可能会提供更多信息。如果你安装了多个pythons,这样就搞砸了GAE,请确保使用GAE中的Python Path首选项指向Apple Python。

答案 2 :(得分:0)

您可能需要手动安装openssl,尽管标头应该通过默认的Xcode安装放在/ usr / include中。 (如果你还没有安装Xcode,你的机器上不太可能有gcc,并且无论如何都会在以后的过程中失败。)