Twisted app fails with error “Failed to load application: No module named OpenSSL.SSL” on OS X
(P)When running a twisted(os x 10.9.3)file via EDOCX1 plus 0(p)字母名称(P)Twisted and SSL import fine in a python shell:(p)字母名称(P)任何关于权利方向的观点?(p)(P)Thanks!(p)
根据提供的信息,我假设您:
- 没有加载pyopenssl(错误表明它试图导入"openssl.ssl",您尝试导入"ssl",我不知道"ssl"是否映射到pyopenssl)。请参阅Twisted的TLS文档。
或
- Twisted运行的是另一个python实例,然后在终端提示下得到什么
更新:
给出了注释中的反馈,并跟踪来自so的信息:检索python模块路径并找到python解释器的完整路径
尝试运行以下命令以查看当前的python路径:
对于Twisted,将以下内容放入文件中,并以与当前运行Twisted相同的方式运行:
1 2 3 4 5 6 7 8 9 10 | from twisted.application.service import Application from twisted.internet import reactor import sys def print_path(): print" ---- The path to the twistd python is:" + str(sys.executable) +" ----" reactor.stop() application = Application("path_test") reactor.callWhenRunning(print_path) |
对于命令行python,只需在交互模式下运行以下命令:
1 2 | import sys print sys.executable |
在我的例子中(运行OS X 10.9.3,使用一个有点定制的Python)
TWSTD:
1 2 3 4 5 6 7 | % twistd -n -y twisted-question-24191967.py 2014-06-13 11:08:19-0400 [-] Log opened. 2014-06-13 11:08:19-0400 [-] twistd 13.2.0 (/usr/bin/python 2.7.5) starting up. 2014-06-13 11:08:19-0400 [-] reactor class: twisted.internet.selectreactor.SelectReactor. 2014-06-13 11:08:19-0400 [-] ---- The path to the twistd python is: /usr/bin/python ---- 2014-06-13 11:08:19-0400 [-] Main loop terminated. 2014-06-13 11:08:19-0400 [-] Server Shut Down. |
交互地:
1 2 3 4 5 6 | >>> import OpenSSL.SSL >>> print OpenSSL.SSL.__file__ /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/OpenSSL/SSL.so >>> import sys >>> print sys.executable /usr/bin/python |