[英]Python problem to install discord.py using pip
我尝试按照说明安装discord.py
模块,但我的代码没有执行。
Traceback (most recent call last):
File "c:/Users/Cyril/Desktop/@Dev/pyDiscord/main.py", line 1, in <module>
import discord
ModuleNotFoundError: No module named 'discord'
我尝试安装所有要求,并且它们都已安装。 当我尝试所有命令时:
pip install discord.py
或者
python -m pip install discord.py
我收到各种消息,但在所有 output 的开头是:
Requirement already satisfied:
我的 IDE 是 Visual Studio Code。 pip
在最后一个版本(20.1.1)上。 我的 Python 版本是 3.8.3。
打开cmd
并运行以下命令:
py -3 -m pip install -U discord.py
The message Collecting discord.py
should appear if discord module is not (properly) installed on your machine, otherwise, try running cmd
as an administrator and do the same installation process, if the error still exists, try reinstalling python
运行此程序以检查错误是否已修复:
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix='>')
@bot.command()
async def ping(ctx):
await ctx.send('pong')
try:
bot.run('token')
except discord.errors.LoginFailure:
print("invalid token")
#remove the exception block if you have a valid token
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.