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

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

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

问题

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

我使用以下代码启动它:

  1. import discord
  2. from discord.ext import commands
  3. print("running")
  4. client = commands.Bot(command_prefix = "c!")
  5. @client.command()
  6. async def hello(ctx):
  7. await ctx.send("hello")
  8. client.run(token)

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

  1. from discord.ext import commands
  2. 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:

  1. import discord
  2. from discord.ext import commands
  3. print("running")
  4. client =commands.Bot(command_prefix = "c!")
  5. @client.command()
  6. async def hello(ctx):
  7. await ctx.send("hello")
  8. client.run(token)

but i keep getting this annoying error:

  1. from discord.ext import commands
  2. 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

  1. pip卸载discord
  2. pip安装discord.py
英文:
  1. pip uninstall discord
  2. 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:

确定