Python Forum

Full Version: Error importing package
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
import discord
from discord.ext import commands

client = commands.Bot(command_prefix= '.')

Token = 'a valid token'

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

client.run(Token)
Error:
Traceback (most recent call last): File "the location of the file", line 2, in <module> from discord.ext import commands ModuleNotFoundError: No module named 'discord.ext'; 'discord' is not a package
I keep getting this error all of a sudden. An hour ago it was still working but now it just keeps on giving me this error. Has anyone got an idea why I get this error?

Thanks in advance!
do you have a file named discord.py? i.e. some file created by you around the time it stopped working ...
(Jan-26-2020, 05:35 PM)buran Wrote: [ -> ]do you have a file named discord.py? i.e. some file created by you around the time it stopped working ...
Ohw shit, yes i have created a file called discord.py. Should i delete it?

(Jan-26-2020, 06:04 PM)julio2000 Wrote: [ -> ]
(Jan-26-2020, 05:35 PM)buran Wrote: [ -> ]do you have a file named discord.py? i.e. some file created by you around the time it stopped working ...
Ohw shit, yes i have created a file called discord.py. Should i delete it?
omg just deleted it and it works again. Thanks a lot!!
it was importing that file, not the package.