No module named ‘discord.ext’; ‘discord’ is not a package

huangapple go评论116阅读模式
英文:

No module named 'discord.ext'; 'discord' is not a package

问题

我正在使用Python开发一个Discord机器人,只是在尝试基础操作。

我使用以下代码启动它:

import discord
from discord.ext import commands
print("running")
client = commands.Bot(command_prefix = "c!")

@client.command()
async def hello(ctx):
   await ctx.send("hello")

client.run(token)

但我一直遇到这个烦人的错误:

from discord.ext import commands
ModuleNotFoundError: No module named 'discord.ext'; 'discord' is not a package

我不确定为什么会出现这个问题。

我尝试重新安装discord.py并更改名称,但都没有起作用!请帮忙!

英文:

I am working on a discord bot in python and just trying to do the basics.

I am using this code to start it up:

import discord
from discord.ext import commands
print("running")
client =commands.Bot(command_prefix = "c!")

@client.command()
async def hello(ctx):
   await ctx.send("hello")
  
client.run(token)

but i keep getting this annoying error:

from discord.ext import commands
ModuleNotFoundError: No module named 'discord.ext'; 'discord' is not a package

I am not sure why this is happenign

I have tried installing discord.py again and rechanging the name but nothing has worked! Pleasehelp!

答案1

得分: 1

pip卸载discord
pip安装discord.py
英文:
pip uninstall discord
pip install discord.py

huangapple
  • 本文由 发表于 2023年7月23日 22:32:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/76748783.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定