【已解答】升级后ssl操作,出现 ImportError: cannot import name ...
为了能快速了解并处理您的问题,请提供以下基础信息:面板、插件版本:11.3系统版本:CentOS7.2.1511 x86_64(Py3.7.9)
问题描述:升级后ssl操作,出现 ImportError: cannot import name 'x509' from 'cryptography.hazmat.bindings._rust' (unknown location)
相关截图(日志、错误):
Traceback (most recent call last):
File "class/acme_v2.py", line 37, in <module>
import OpenSSL
File "/www/server/panel/pyenv/lib/python3.7/site-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import SSL, crypto
File "/www/server/panel/pyenv/lib/python3.7/site-packages/OpenSSL/SSL.py", line 15, in <module>
from cryptography import x509
File "/www/server/panel/pyenv/lib/python3.7/site-packages/cryptography/x509/__init__.py", line 7, in <module>
from cryptography.x509 import certificate_transparency, verification
File "/www/server/panel/pyenv/lib/python3.7/site-packages/cryptography/x509/certificate_transparency.py", line 8, in <module>
from cryptography.hazmat.bindings._rust import x509 as rust_x509
ImportError: cannot import name 'x509' from 'cryptography.hazmat.bindings._rust' (unknown location)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/www/server/panel/BTPanel/__init__.py", line 2559, in publicObject
res = run_obj.run(toObject, defs, get)
File "/www/server/panel/BTPanel/__init__.py", line 2506, in run
result = getattr(toObject, get.action)(get)
File "/www/server/panel/class/panelSite.py", line 2762, in GetSSL
import acme_v2
File "class/acme_v2.py", line 40, in <module>
import OpenSSL
File "/www/server/panel/pyenv/lib/python3.7/site-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import SSL, crypto
File "/www/server/panel/pyenv/lib/python3.7/site-packages/OpenSSL/SSL.py", line 15, in <module>
from cryptography import x509
File "/www/server/panel/pyenv/lib/python3.7/site-packages/cryptography/x509/__init__.py", line 7, in <module>
from cryptography.x509 import certificate_transparency, verification
File "/www/server/panel/pyenv/lib/python3.7/site-packages/cryptography/x509/certificate_transparency.py", line 8, in <module>
from cryptography.hazmat.bindings._rust import x509 as rust_x509
ImportError: cannot import name 'x509' from 'cryptography.hazmat.bindings._rust' (unknown location)
btpip install cryptography==42.0.5
btpip install pyOpenSSL==24.0.0
bt 1
执行上面命令重试 阿珂 发表于 2025-11-25 15:14
执行上面命令重试
试了,安装好后,恢复正常,但是SSL管理这里依然出错。然后重启服务器后,还是一样的全部错误 不需要重启服务器
检查一下cryptography和pyOpenSSL库的版本是什么
不对的话,再执行上面的命令指定版本安装一下
页:
[1]