【发布时间】:2021-01-22 05:22:06
【问题描述】:
我对在我的 Mac 而不是 Windows 上编写 Discord 机器人非常陌生,并且在尝试运行我的 Python 文件时遇到了麻烦。我使用 Visual Studio Code 和 Microsoft 的 Python 扩展运行我的 Python 文件。我单击右上角的绿色播放图标,VSC 在终端中为我运行它。这通常适用于 Windows,但由于某种原因,当我尝试运行我的时会遇到大量错误。
这些是错误:
mika@Mikas-Air python-test % /Library/Frameworks/Python.framework/Versions/3.8/bin/python3 /Users/mika/Desktop/python-test/test.py
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/aiohttp/connector.py", line 936, in _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", line 1050, in create_connection
transport, protocol = await self._create_connection_transport(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py", line 1080, in _create_connection_transport
await waiter
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/sslproto.py", line 529, in data_received
ssldata, appdata = self._sslpipe.feed_ssldata(data)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/sslproto.py", line 189, in feed_ssldata
self._sslobj.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py", line 944, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/mika/Desktop/python-test/test.py", line 8, in <module>
client.run('NzU1NDAxMTE0NTU5NDQ3MDYx.X2CwHA.6fn_XQKpuAg9V5prid_W2bof9qU')
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/discord/client.py", line 678, in run
return future.result()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/discord/client.py", line 658, in runner
await self.start(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/discord/client.py", line 621, in start
await self.login(*args, bot=bot)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/discord/client.py", line 472, in login
await self.http.static_login(token.strip(), bot=bot)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/discord/http.py", line 288, in static_login
data = await self.request(Route('GET', '/users/@me'))
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/discord/http.py", line 185, in request
async with self.__session.request(method, url, **kwargs) as r:
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/aiohttp/client.py", line 1012, in __aenter__
self._resp = await self._coro
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/aiohttp/client.py", line 480, in _request
conn = await self._connector.connect(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/aiohttp/connector.py", line 523, in connect
proto = await self._create_connection(req, traces, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/aiohttp/connector.py", line 858, in _create_connection
_, proto = await self._create_direct_connection(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/aiohttp/connector.py", line 1004, in _create_direct_connection
raise last_exc
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/aiohttp/connector.py", line 980, in _create_direct_connection
transp, proto = await self._wrap_create_connection(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/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: unable to get local issuer certificate (_ssl.c:1123)')]
我不知道这些错误是什么意思,并用谷歌搜索了它们,但没有找到任何有用的答案。
我在 Python 文件中的代码:
import discord
from discord.ext import commands
client = commands.Bot(command_prefix="e!")
client.run('My Bot Token')
我有一台 Macbook Air 2019,操作系统是 10.15.7,我的 Python 解释器是 3.8.5 64 位。我目前使用的 Discord.py 版本是最新的,Discord.py 1.5.0 和包含语音支持的版本。我检查了它是否安装并在我的终端中使用了pip install discord.py 命令,它确认我已经安装了它:Requirement already satisfied: discord.py in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (1.5.0)
我的代码编辑器是 Visual Studio Code
【问题讨论】:
-
您是否尝试过重置您的令牌?而且您的令牌似乎在回溯中,您应该编辑它并更改您的令牌。
-
@Nurqm 谢谢你告诉我哈哈。只需重置我的令牌,同样的问题。
标签: python discord.py