【发布时间】:2020-04-12 03:32:34
【问题描述】:
我正在使用 Pycharm 和 python 3.8 以及最新版本的不和谐。我试图运行这个脚本,但得到了这个错误。任何人都可以帮忙吗?
import discord
TOKEN = 'xxxxx'
client = discord.Client()
@client.event
async def on_message(message):
# we do not want the bot to reply to itself
if message.author == client.user:
return
if message.content.startswith('!hello'):
msg = 'Hello {0.author.mention}'.format(message)
await client.send_message(message.channel, msg)
@client.event
async def on_ready():
print('Logged in as')
print(client.user.name)
print(client.user.id)
print('------')
client.run(TOKEN)
----- 下面错误-------
/Users/mellie/PycharmProjects/Dominations/venv/bin/python /Users/mellie/PycharmProjects/Dominations/Domi.py Traceback(大多数 最近通话最后):文件 “/Users/mellie/PycharmProjects/Dominations/venv/lib/python3.8/site-packages/aiohttp/connector.py”, 第 936 行,在 _wrap_create_connection return await self._loop.create_connection(*args, **kwargs) # type: ignore # noqa File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py", 第 1042 行,在 create_connection 中 传输,协议=等待self._create_connection_transport(文件 "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py", 第 1072 行,在 _create_connection_transport 中 等待服务员文件“/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/sslproto.py”, 第 529 行,在 data_received 中 ssldata,appdata = self._sslpipe.feed_ssldata(数据)文件“/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/sslproto.py”, 第 189 行,在 feed_ssldata 中 self._sslobj.do_handshake() 文件“/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py”, 第 944 行,在 do_handshake 中 self._sslobj.do_handshake() ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败:无法获取 本地颁发者证书 (_ssl.c:1108)
上述异常是以下异常的直接原因:
Traceback(最近一次调用最后一次):文件 “/Users/mellie/PycharmProjects/Dominations/Domi.py”,第 24 行,在 client.run(TOKEN) 文件“/Users/mellie/PycharmProjects/Dominations/venv/lib/python3.8/site-packages/discord/client.py”, 第 640 行,运行中 返回 future.result() 文件“/Users/mellie/PycharmProjects/Dominations/venv/lib/python3.8/site-packages/discord/client.py”, 第 621 行,在亚军中 等待 self.start(*args, **kwargs) 文件“/Users/mellie/PycharmProjects/Dominations/venv/lib/python3.8/site-packages/discord/client.py”, 第 584 行,开始 等待 self.login(*args, bot=bot) 文件“/Users/mellie/PycharmProjects/Dominations/venv/lib/python3.8/site-packages/discord/client.py”, 第 442 行,登录 等待self.http.static_login(token.strip(),bot = bot)文件“/Users/mellie/PycharmProjects/Dominations/venv/lib/python3.8/site-packages/discord/http.py”, 第 256 行,在 static_login 中 数据 = 等待 self.request(Route('GET', '/users/@me')) 文件“/Users/mellie/PycharmProjects/Dominations/venv/lib/python3.8/site-packages/discord/http.py ", 第 160 行,应要求提供 async with self.session.request(method, url, **kwargs) as r: File “/Users/mellie/PycharmProjects/Dominations/venv/lib/python3.8/site-packages/aiohttp/client.py”, 第 1012 行,在 __aenter self._resp = 等待 self._coro 文件“/Users/mellie/PycharmProjects/Dominations/venv/lib/python3.8/site-packages/aiohttp/client.py”, 第 480 行,在 _request 中 conn =等待self._connector.connect(文件“/Users/mellie/PycharmProjects/Dominations/venv/lib/python3.8/site-packages/aiohttp/connector.py”, 第 523 行,连接中 proto = await self._create_connection(req, traces, timeout) 文件“/Users/mellie/PycharmProjects/Dominations/venv/lib/python3.8/site-packages/aiohttp/connector.py”, 第 858 行,在 _create_connection 中 _,原型 = 等待 self._create_direct_connection(文件“/Users/mellie/PycharmProjects/Dominations/venv/lib/python3.8/site-packages/aiohttp/connector.py”, 第 1004 行,在 _create_direct_connection 提出 last_exc 文件“/Users/mellie/PycharmProjects/Dominations/venv/lib/python3.8/site-packages/aiohttp/connector.py”, 第 980 行,在 _create_direct_connection 中 传输,原型 = 等待 self._wrap_create_connection(文件“/Users/mellie/PycharmProjects/Dominations/venv/lib/python3.8/site-packages/aiohttp/connector.py”, 第 938 行,在 _wrap_create_connection 引发 ClientConnectorCertificateError(aiohttp.client_exceptions.ClientConnectorCertificateError:不能 连接到主机 discordapp.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败: 无法获取本地颁发者证书 (_ssl.c:1108)')]
进程以退出代码 1 结束
【问题讨论】:
-
您是如何访问互联网的?如果您使用一些公共 wifi,请确保不和谐没有被主机防火墙阻止。谢谢
-
这是家庭互联网。
标签: python discord.py