问题描述
树莓派ubuntu系统下python3执行报错如下:
File "/usr/share/python-wheels/urllib3-1.25.8-py2.py3-none-any.whl/urllib3/contrib/pyopenssl.py", line 46, in <module>
File "/usr/lib/python3/dist-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import crypto, SSL
File "/usr/lib/python3/dist-packages/OpenSSL/crypto.py", line 1553, in <module>
class X509StoreFlags(object):
File "/usr/lib/python3/dist-packages/OpenSSL/crypto.py", line 1573, in X509StoreFlags
CB_ISSUER_CHECK = _lib.X509_V_FLAG_CB_ISSUER_CHECK
AttributeError: module 'lib' has no attribute 'X509_V_FLAG_CB_ISSUER_CHECK'
原因分析:
pyOpenSSL版本与python版本不匹配文章来源:https://www.toymoban.com/news/detail-601701.html
解决方案:
重新安装pip和pyOpenSSL文章来源地址https://www.toymoban.com/news/detail-601701.html
# 卸载pip
sudo apt-get remove python3-pip
# 下载pip
wget https://files.pythonhosted.org/packages/4b/30/e15b806597e67057e07a5acdc135216ccbf76a5f1681a324533b61066b0b/pip-22.2.2.tar.gz
# 解压
tar xf pip-22.2.2.tar.gz
# 安装
cd pip-22.2.2
python3 setup.py install
# 查询版本
root@ubuntu:/home/ubuntu/# pip3 --version
pip 22.2.2 from /usr/local/lib/python3.8/dist-packages/pip-22.2.2-py3.8.egg/pip (python 3.8)
- 安装匹配的 pyOpenSSL
>root@ubuntu:/home/ubuntu/# pip3 install pyOpenSSL --upgrade
Requirement already satisfied: pyOpenSSL in /usr/lib/python3/dist-packages (19.0.0)
Collecting pyOpenSSL
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0xffff968926a0>: Failed to establish a new connection: [Errno 101] Network is unreachable')': /packages/b7/6d/d7377332703ffd8821878794aca4fb54637da654bf3e467ffb32109c2147/pyOpenSSL-23.1.1-py3-none-any.whl
Downloading pyOpenSSL-23.1.1-py3-none-any.whl (57 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 57.9/57.9 kB 252.1 kB/s eta 0:00:00
Requirement already satisfied: cryptography<41,>=38.0.0 in /usr/local/lib/python3.8/dist-packages (from pyOpenSSL) (40.0.2)
Requirement already satisfied: cffi>=1.12 in /usr/local/lib/python3.8/dist-packages (from cryptography<41,>=38.0.0->pyOpenSSL) (1.15.1)
Requirement already satisfied: pycparser in /usr/local/lib/python3.8/dist-packages (from cffi>=1.12->cryptography<41,>=38.0.0->pyOpenSSL) (2.21)
Installing collected packages: pyOpenSSL
Attempting uninstall: pyOpenSSL
Found existing installation: pyOpenSSL 19.0.0
Uninstalling pyOpenSSL-19.0.0:
Successfully uninstalled pyOpenSSL-19.0.0
Successfully installed pyOpenSSL-23.1.1
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
到了这里,关于【Python】AttributeError: module ‘lib‘ has no attribute ‘X509_V_FLAG_CB_ISSUER_CHECK‘的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!