【发布时间】:2020-07-15 19:34:12
【问题描述】:
在 python 3.6.6 上使用此代码:
import discord
client = discord.Client()
@client.event
async def on_ready():
print('Logged in!')
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('/'):
await message.channel.send('Got command')
client.run('Njk1*******************************************************')
我最终得到了一个很长的回溯:
Traceback(最近一次调用最后一次): _wrap_create_connection 中的文件“/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/aiohttp/connector.py”,第 936 行 return await self._loop.create_connection(*args, **kwargs) # type: ignore # noqa 文件“/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/base_events.py”,第 804 行,在 create_connection 袜子,协议工厂,ssl,服务器主机名) _create_connection_transport 中的文件“/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/base_events.py”,第 830 行 服务员的收益 文件“/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/sslproto.py”,第 505 行,在 data_received ssldata,appdata = self._sslpipe.feed_ssldata(数据) 文件“/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/sslproto.py”,第 201 行,在 feed_ssldata self._sslobj.do_handshake() 文件“/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py”,第 689 行,在 do_handshake self._sslobj.do_handshake() ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败 (_ssl.c:841)
上述异常是以下异常的直接原因:
Traceback (most recent call last):
File "/Users/eric/Desktop/ Python_Files/lib/discordbot/discordbot.py", line 21, in <module>
client.run('Njk1*******************************************************')
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/discord/client.py", line 640, in run
return future.result()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/discord/client.py", line 621, in runner
await self.start(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/discord/client.py", line 584, in start
await self.login(*args, bot=bot)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/discord/client.py", line 442, in login
await self.http.static_login(token.strip(), bot=bot)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/discord/http.py", line 261, in static_login
data = await self.request(Route('GET', '/users/@me'))
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/discord/http.py", line 165, in request
async with self.__session.request(method, url, **kwargs) as r:
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/aiohttp/client.py", line 1012, in __aenter__
self._resp = await self._coro
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/aiohttp/client.py", line 483, in _request
timeout=real_timeout
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/aiohttp/connector.py", line 523, in connect
proto = await self._create_connection(req, traces, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/aiohttp/connector.py", line 859, in _create_connection
req, traces, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/aiohttp/connector.py", line 1004, in _create_direct_connection
raise last_exc
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/aiohttp/connector.py", line 986, in _create_direct_connection
req=req, client_error=client_error)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/aiohttp/connector.py", line 941, in _wrap_create_connection
raise ClientConnectorSSLError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorSSLError: Cannot connect to host discordapp.com:443 ssl:default [[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:841)]
谁能帮我解决这个问题? 这可能是我的系统有问题,因为我在网上搜索了一些其他教程,但没有一个有用,而且我的互联网连接很好。 (我无法对异常的第一部分进行编码,因为它有“太多代码”)
【问题讨论】:
标签: python-3.x discord.py