discord.py 错误 - ClientConnectorCertificateError [英] discord.py Error - ClientConnectorCertificateError

查看:114
本文介绍了discord.py 错误 - ClientConnectorCertificateError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试运行我的 python discord bot 时出错.这是我的代码:

I have an error trying to run my python discord bot. Here's my code:

import discord

client = discord.Client()

@client.event
async def on_ready():
    print('We have logged in as {0.user}'.format(client))

@client.event
async def on_message(message):
    if message.author == client.user:
        return None

    if message.content.startswith('$hello'):
        await message.channel.send('Hello!')

client.run('<redacted>')

当我运行这个时,我得到以下错误代码:aiohttp.client_exceptions.ClientConnectorCertificateError: 无法连接到主机 discord.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify失败:证书已过期 (_ssl.c:1123)')]完整的错误回溯:

When I run this, I get the following error code: aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host discord.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1123)')] Full error traceback:

Traceback (most recent call last):
  File "C:\Users\shalev\AppData\Local\Programs\Python\Python38\lib\site-packages\aiohttp\connector.py", line 936, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)  # type: ignore  # noqa
  File "C:\Users\shalev\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 1050, in create_connection      
    transport, protocol = await self._create_connection_transport(
  File "C:\Users\shalev\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 1080, in _create_connection_transport
    await waiter
  File "C:\Users\shalev\AppData\Local\Programs\Python\Python38\lib\asyncio\sslproto.py", line 529, in data_received
    ssldata, appdata = self._sslpipe.feed_ssldata(data)
  File "C:\Users\shalev\AppData\Local\Programs\Python\Python38\lib\asyncio\sslproto.py", line 189, in feed_ssldata
    self._sslobj.do_handshake()
  File "C:\Users\shalev\AppData\Local\Programs\Python\Python38\lib\ssl.py", line 944, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1123)  

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\shalev\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\shalev\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "c:\Users\shalev\.vscode\extensions\ms-python.python-2020.9.111407\pythonFiles\lib\python\debugpy\__main__.py", line 45, in <module>
    cli.main()
  File "c:\Users\shalev\.vscode\extensions\ms-python.python-2020.9.111407\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 430, in main
    run()
  File "c:\Users\shalev\.vscode\extensions\ms-python.python-2020.9.111407\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 267, in run_file
    runpy.run_path(options.target, run_name=compat.force_str("__main__"))
  File "C:\Users\shalev\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 265, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "C:\Users\shalev\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "C:\Users\shalev\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "f:\python projects\among us bot.py", line 17, in <module>
    client.run('<redacted>')
  File "C:\Users\shalev\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 678, in run
    return future.result()
  File "C:\Users\shalev\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 658, in runner
    await self.start(*args, **kwargs)
  File "C:\Users\shalev\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 621, in start
    await self.login(*args, bot=bot)
  File "C:\Users\shalev\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 472, in login
    await self.http.static_login(token.strip(), bot=bot)
  File "C:\Users\shalev\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\http.py", line 288, in static_login     
    data = await self.request(Route('GET', '/users/@me'))
  File "C:\Users\shalev\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\http.py", line 185, in request
    async with self.__session.request(method, url, **kwargs) as r:
  File "C:\Users\shalev\AppData\Local\Programs\Python\Python38\lib\site-packages\aiohttp\client.py", line 1012, in __aenter__    
    self._resp = await self._coro
  File "C:\Users\shalev\AppData\Local\Programs\Python\Python38\lib\site-packages\aiohttp\client.py", line 480, in _request       
    conn = await self._connector.connect(
  File "C:\Users\shalev\AppData\Local\Programs\Python\Python38\lib\site-packages\aiohttp\connector.py", line 523, in connect     
    proto = await self._create_connection(req, traces, timeout)
  File "C:\Users\shalev\AppData\Local\Programs\Python\Python38\lib\site-packages\aiohttp\connector.py", line 858, in _create_connection
    _, proto = await self._create_direct_connection(
  File "C:\Users\shalev\AppData\Local\Programs\Python\Python38\lib\site-packages\aiohttp\connector.py", line 1004, in _create_direct_connection
    raise last_exc
  File "C:\Users\shalev\AppData\Local\Programs\Python\Python38\lib\site-packages\aiohttp\connector.py", line 980, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
  File "C:\Users\shalev\AppData\Local\Programs\Python\Python38\lib\site-packages\aiohttp\connector.py", line 938, in _wrap_create_connection
    raise ClientConnectorCertificateError(
aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host discord.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1123)')]

谁能帮我解决这个问题?

Can anyone help me with this?

推荐答案

尝试更新 discord.py.

Try updating discord.py.

pip install -U discord.py

亲自为我工作.

这篇关于discord.py 错误 - ClientConnectorCertificateError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆