Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/292.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
discord.py上的Python SSL错误:SSL.SSLCertVerificationError:证书验证失败:无法获取本地颁发者证书(_SSL.c:1056)_Python_Python 3.x_Ssl_Certificate_Raspbian - Fatal编程技术网

discord.py上的Python SSL错误:SSL.SSLCertVerificationError:证书验证失败:无法获取本地颁发者证书(_SSL.c:1056)

discord.py上的Python SSL错误:SSL.SSLCertVerificationError:证书验证失败:无法获取本地颁发者证书(_SSL.c:1056),python,python-3.x,ssl,certificate,raspbian,Python,Python 3.x,Ssl,Certificate,Raspbian,错误 ssl.SSLCertVerificationError:[ssl:证书\u验证\u失败]证书验证失败:无法获取本地颁发者证书(\u ssl.c:1056) 验证证书时SSL握手失败 aiohttp.client_exceptions.ClientConnectorCertificateError:无法连接到主机discordapp.com:443 ssl:True[SSLCertVerificationError:(1),[ssl:CERTIFICATE_Verification_FAI

错误

ssl.SSLCertVerificationError:[ssl:证书\u验证\u失败]证书验证失败:无法获取本地颁发者证书(\u ssl.c:1056) 验证证书时SSL握手失败

aiohttp.client_exceptions.ClientConnectorCertificateError:无法连接到主机discordapp.com:443 ssl:True[SSLCertVerificationError:(1),[ssl:CERTIFICATE_Verification_FAILED]CERTIFICATE Verification FAILED:无法获取本地颁发者证书(_ssl.c:1056)]

完全回溯(156行):

调试信息

我正在用Python 3.7.3在Raspberry Pi 3上运行完全更新的Raspbian Buster

uname-a的输出:

Linux hostname 4.19.75-v7+ #1270 SMP Tue Sep 24 18:45:11 BST 2019 armv7l GNU/Linux
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 10 (buster)
Release:        10
Codename:       buster
lsb_发布-a的输出

Linux hostname 4.19.75-v7+ #1270 SMP Tue Sep 24 18:45:11 BST 2019 armv7l GNU/Linux
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 10 (buster)
Release:        10
Codename:       buster
pip冻结的输出

aiohttp==3.5.4
async-timeout==3.0.1
attrs==19.3.0
certifi==2019.9.11
chardet==3.0.4
discord.py==1.2.4
idna==2.8
multidict==4.5.2
pkg-resources==0.0.0
websockets==6.0
yarl==1.3.0
我尝试过的

我所有的在线搜索都给出了以下两个建议之一:

  • 使用pip安装
    certifi
    • 我已经安装了它,它不会改变任何东西
  • /Applications/Python 3.X/
    文件夹中运行
    Install Certificates.command
    • 这是Mac特有的。一般来说,所有提到这个错误的地方都是在Mac上
  • 最小复制示例

    创建一个venv,并安装软件包

    sudo apt-get update
    sudo apt-get dist-upgrade
    sudo apt-get install ca-certificates python3-venv python3-pip
    
    python3 -m venv env
    source env/bin/activate
    python3 -m pip install -U pip
    python3 -m pip install -U setuptools wheel
    python3 -m pip install -U discord.py certifi
    
    打开python3提示符,然后运行:

    导入不一致
    client=discord.client()
    client.run(“token”)#此处发生错误
    
    在运行Linux和相同Python版本及软件包的PC上,我没有遇到同样的错误

    有什么办法可以做到这一点吗

    • 忽略ssl证书验证检查(如curl上的
      --unsecure
      标志),或
    • 正确安装丢失的证书
    尝试这样做:

    import ssl
    ctx = ssl.create_default_context()
    ctx.check_hostname = False
    ctx.verify_mode = ssl.CERT_NONE
    
    html = urllib.request.urlopen('https://blahblah.com/something', context=ctx).read()
    
    这将阻止对证书进行验证。否则,您将需要安装它。

    尝试执行以下操作:

    import ssl
    ctx = ssl.create_default_context()
    ctx.check_hostname = False
    ctx.verify_mode = ssl.CERT_NONE
    
    html = urllib.request.urlopen('https://blahblah.com/something', context=ctx).read()
    
    这将阻止对证书进行验证。否则,您将需要安装它