0

I have programmed a discord bot with python and I installed all discord.py libraries. the problem is when I run the script it said no module found but I already install everything the errors are: in the following picture enter image description here

also the same error appear for the libraries like the photos above any help??

MCLB
  • 29
  • 1
  • 1
  • 8
  • Can you post your code? – Guac Mar 13 '21 at 06:31
  • the problem is from import not from the code: `import requests, os, discord from discord.ext import commands from dotenv import load_dotenv from bs4 import BeautifulSoup client = commands.Bot(command_prefix="!") load_dotenv() TOKEN = os.getenv('DISCORD_TOKEN') GUILD_ID = os.getenv('DISCORD_GUILD_ID') ID_TOKEN = os.getenv('ID_TOKEN') USER_AGENT = os.getenv('USER_AGENT')` – MCLB Mar 13 '21 at 06:34
  • Did you install `discord.py` and not `discord`? – duckboycool Mar 13 '21 at 06:37
  • yes, the error not for `discord` only for other libraries also, look at the picture above – MCLB Mar 13 '21 at 06:39
  • Have you looked at [this question](https://stackoverflow.com/questions/61052890/import-could-not-be-resolved-reported-by-pyright)? – duckboycool Mar 13 '21 at 06:39
  • yeah, I looked at it same problem – MCLB Mar 13 '21 at 06:49
  • when I run the script, it said this: ` import requests, os, discord ModuleNotFoundError: No module named 'requests'` but I already install every library – MCLB Mar 13 '21 at 06:50
  • ohh, it works i will post the solution – MCLB Mar 13 '21 at 07:01

3 Answers3

9

I had the same issue. The solution is to change the Python Interpreter. You can do it by Ctrl+Shift+P and choose "Python: Select Interpreter" in visual studio code.

AEM
  • 1,354
  • 8
  • 20
  • 30
KKK
  • 109
  • 1
  • 7
  • I'll add that if you want to see which Python version you should be using (i.e. the version that has the discord package installed), just do `pip show discord` and look for the location folder (/python310, /python39, etc) – joeyagreco Jul 30 '23 at 05:25
1

I was having a lot of troubles with stuff I got with pip install and they were installed successfully, but when I tried to import them, they didn't import

I found out that for me, some of the installs get installed to a separate folder, and not the correct folder that they need to be in to import.

If you try installing it again with pip install, then it will say you already have it installed and it will give you the location where the file is, and I copied the files from there and pasted them into the correct location which is (on windows)

C:\Users{Username}\AppData\Local\Programs\Python{Python Version}\Lib\site-packages

I was trying to find a place to share this and this was the closest to the issue, so I hope it helps!

MCLB
  • 29
  • 1
  • 1
  • 8
0

I was having a similar issue in VS code with a file containing a function and another file that was trying to import that function. My problem was that although they were saved in the same folder I hadn't opened that folder in VS code.

Simply going File>Open Folder... and then navigating to the folder containing the file with the function and the file that I wanted to import the function from resolved the issue.

Sloth87
  • 435
  • 5
  • 8