python-3.x - 导入 eventlet SSL 导致:ModuleNotFoundError: No module named 'OpenSSL.tsafe'
问题描述
为什么在尝试导入 eventlet 的 SSL 模块时出现以下导入错误:
ModuleNotFoundError: No module named 'OpenSSL.tsafe'
eventlet 的 OpenSSL 是否与最新版本的 pyOpenSSL 不兼容?
复制步骤
使用以下 Pipenv:
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
[packages]
pyOpenSSL = "*"
eventlet = "*"
[requires]
python_version = "3"
使用该文件创建一个 pipenv:
$ pipenv install
Creating a virtualenv for this project…
Pipfile: /tmp/Pipfile
Using /usr/local/bin/python3.8 (3.8.3) to create virtualenv…
...
Successfully created virtual environment!
...
现在导入 eventlet.green.OpenSSL.SSL:
$ pipenv run python
Python 3.8.3 (default, Jun 29 2020, 18:02:49)
[GCC 8.3.1 20190311 (Red Hat 8.3.1-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from eventlet.green.OpenSSL import SSL
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/myuser/.local/share/virtualenvs/tmp-XVr6zr33/lib/python3.8/site-packages/eventlet/green/OpenSSL/__init__.py", line 3, in <module>
from . import tsafe
File "/home/myuser/.local/share/virtualenvs/tmp-XVr6zr33/lib/python3.8/site-packages/eventlet/green/OpenSSL/tsafe.py", line 1, in <module>
from OpenSSL.tsafe import *
ModuleNotFoundError: No module named 'OpenSSL.tsafe'
>>>
解决方案
经过一段时间的挖掘,看起来 eventlet 目前确实不适用于截至本文发布时四天前发布的最新 20.0.0 PyOpenSSL 包。我向 eventlet 提出了一个问题:
https://github.com/eventlet/eventlet/issues/671
在更新 eventlet 之前,我们必须将 PyOpenSSL 固定到以前的 19.1.0 版本(根据问题中的 Pipfile):
pyOpenSSL = "==19.1.0"
推荐阅读
- symfony - 从扩展它的每个模板访问基本模板变量
- linux - 树莓派导入tensorflow分割错误
- swift - 如何在 Swift 中获取 MacOS 上打开的窗口列表?
- google-cloud-platform - GCP上的设计服务
- optimization - 如何在 Pytorch 中优化较低的 Cholesky 参数?
- jquery - HTML多选标签如何通过点击事件选择多个选项
- reactjs - 更改所选元素 onMouseEnter- React
- c++ - 'localtime_s': 不是 VS2015 中'std' 的成员
- laravel - 试图在 Facebook twitter LinkedIn 上分享帖子无法使用 Laravel 发布或分享的第三方帐户
- javascript - 如何将 Javascript 作为字符串传递给 HTML 函数