开发者

How to install Python SSL module on OSX?

When I deploy my google app engine project, I get the following warning:

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.

I downloaded the package, but when I try

python setup.py build

I get the following error output:

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

What do I need to do to install it, is it a path issue or some开发者_开发技巧thing?


Fixed by installing pycrypto first, following the instructions from here and using the insight from an answer to this question.

The full command line I used for the eventual build was:

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


The stock Apple python on both 10.5 and 10.6 includes the ssl module (unclear about earlier versions):

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'

(from 10.5.8)

You could actually get that error message from appengine_rpc.py even if you have ssl - you need to make sure that your GAE download has:

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

If you have both of those things, try doing:

import google.appengine.tools.https_wrapper

Which should work with the stock Apple python, but if it doesn't the error messages might be more informative. If you have multiple pythons installed such that one is screwing up GAE, make sure to use the Python Path preference in GAE to point to the Apple Python.


You may need to manually install openssl, although the headers should be placed in /usr/include by the default Xcode installation. (If you haven't installed Xcode, it's unlikely you have gcc on your machine, and the build would fail later in the process anyway.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜