Home > Software engineering >  ModuleNotFoundError: No module named 'discord' or 'Python' error (in Atom)
ModuleNotFoundError: No module named 'discord' or 'Python' error (in Atom)

Time:07-04

Yes, I'm writing a discord bot. I'm beginner and at the very beginning, but I get to the point. I have my code here and there, and I really doubt the problem is with the code. (please note if it is) But when I try to run this code, I'm doing 2 commands.

First is python3 bot.py, when i'd try to run it, it simply says Python. I encountered the same in VS Code earlier, and all I did was adding python to environment variables, and it worked perfectly. But in Atom, it doesn't says anything except just the python word. Second is just python bot.py, when I try it, I get another error:

ModuleNotFoundError: No module named 'discord'

same goes if I do import discord.py

Tried downloading many things, none worked.

Image with original code

Image with python3 error

Image with python error

CodePudding user response:

First of all, if you are new to python programming language, I strongly recommend you to use some kind of virtual environment to separate installed packages of different projects on your system. you could use venv, pipenv, or other virtual enviroments. This tutorial will help you with virtual enviroments

Secondly from the readthedocs page of the discord.py project, you how see how you can install this module:

You can get the library directly from PyPI:

python3 -m pip install -U discord.py

If you are using Windows, then the following should be used instead:

py -3 -m pip install -U discord.py

if you read further you can find how to install inside a virtual environment.

CodePudding user response:

You have to install the module in the terminal

pip3 install discord.py
  • Related