【问题标题】:Importing eventlet SSL results in: ModuleNotFoundError: No module named 'OpenSSL.tsafe'导入 eventlet SSL 导致:ModuleNotFoundError: No module named 'OpenSSL.tsafe'
【发布时间】:2021-03-13 20:45:49
【问题描述】:

为什么我在尝试导入 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'
>>> 

【问题讨论】:

  • 嗯。深入研究这些包,我注意到 PyOpenSSL 刚刚创建了一个 20.0.0 版本,它删除了 tsafe.py。也许 eventlet 需要更新?

标签: python-3.x pyopenssl eventlet


【解决方案1】:

经过一段时间的研究,似乎 eventlet 目前确实不适用于截至本文发布时四天前发布的最新 20.0.0 PyOpenSSL 包。我向 eventlet 提交了一个问题:

https://github.com/eventlet/eventlet/issues/671

在更新 eventlet 之前,我们必须将 PyOpenSSL 固定到以前的 19.1.0 版本(根据问题中的 Pipfile):

pyOpenSSL = "==19.1.0"

【讨论】:

    猜你喜欢
    • 2023-02-02
    • 2020-10-03
    • 1970-01-01
    • 2022-11-18
    • 1970-01-01
    • 1970-01-01
    • 2018-06-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多