首页 > 解决方案 > 使用 discord.py 模块创建不和谐机器人时出错。我认为这与使用 anaconda 进行安装有关

问题描述

如果我在 python 中运行以下代码,则会出现错误。

import discord
from discord.ext import commands

TOKEN = "token"

client = commands.Bot(command_prefix = "rps/")

@client.event
async def on_ready():
    print ('ready')

client.run("token")

错误:

回溯(最后一次调用):文件“/Users/timothy/Library/Python/3.6/lib/python/site-packages/aiohttp/connector.py”,第 822 行,在 _wrap_create_connection return await self._loop.create_connection(* args,**kwargs)文件“/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/base_events.py”,第 804 行,在 create_connection sock、protocol_factory、ssl、server_hostname)文件“/ Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/base_events.py”,第 830 行,在 _create_connection_transport 中从服务员文件中产出“/Library/Frameworks/Python.framework/Versions/3.6/lib/ python3.6/asyncio/sslproto.py”,第 505 行,在 data_received ssldata,appdata = self._sslpipe.feed_ssldata(data) 文件“/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:833)

上述异常是以下异常的直接原因:

Traceback(最近一次通话最后):文件“/Users/timothy/Documents/coding stuff/python/Test bot/test bot.py”,第 12 行,在 client.run(TOKEN) 文件“/Users/timothy/Library/ Python/3.6/lib/python/site-packages/discord/client.py”,第 571 行,在运行中返回 task.result() 文件“/Users/timothy/Library/Python/3.6/lib/python/site-packages /discord/client.py”,第 478 行,开始

我认为这与我使用 $conda install discord.py 安装软件包的方式有关。有谁知道我做错了什么?python确实识别模块

标签: pythonanacondadiscorddiscord.py

解决方案


尝试使用 pip ('pip install discord.py') 安装 discord.py 模块!


推荐阅读