A
A
Alexander Korolev2021-03-17 00:23:05
PyCharm
Alexander Korolev, 2021-03-17 00:23:05

Why can't Python find modules installed via pip?

This is what my Python test code looks like:

import discord
from discord.ext import commands
from config import settings

bot = commands.Bot(command_prefix = settings['prefix']) # Since we specified a prefix in settings, access the dictionary with the key prefix.

@bot.command() # Don't pass the pass_context argument as it was needed in older versions.
async def hello(ctx): # Create a function and pass argument ctx.
author = ctx.message.author # Declare an author variable and write information about the author there.

await ctx.send(f'Hello, {author.mention}!') # Display a message mentioning the author by accessing the author variable.

bot.run(settings['token']) # Access the settings dictionary with the token key to get the token

And after trying to run via cmd, it gives the following error:

Traceback (most recent call last):
File "YoungOrnn.py", line 1, in
import discord
ModuleNotFoundError: No module named 'discord'

This error occurs not only with this library, but also with others. Please help me with solving this problem, since I myself am not very familiar with Python and its nuances. I have a slight suggestion that I may have problems with the interpreter

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alexbprofit, 2021-03-17
@AlexAnDronX

Try to install again after creating a new project in virtualenv.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question