【Python】AttributeError: module ‘lib‘ has no attribute ‘X509_V_FLAG_CB_ISSUER_CHECK‘

这篇具有很好参考价值的文章主要介绍了【Python】AttributeError: module ‘lib‘ has no attribute ‘X509_V_FLAG_CB_ISSUER_CHECK‘。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

问题描述

树莓派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版本不匹配

解决方案:

重新安装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)
  1. 安装匹配的 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模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包