You're working with one of the most common Python + VS Code environment issues — Python interpreter mismatch. This happens when your code editor (VS Code) is not using the same Python interpreter where discord.py is installed.
Even though the module is installed correctly (you confirmed via CLI and help>modules), VS Code might be running the script using a different interpreter, which doesn’t have discord.py.
You already know it's here:
C:\Users\MYUSER\AppData\Local\Programs\Python\Python313\
You can double-check by running in the command prompt:
Where python
or
py -3 -c "import sys; print(sys.executable)"
In VS Code:
Press Ctrl+Shift+P(or F!) to open the command palette.
Type:Python: Select Interpreter
Pick the interpreter that matches this path:
C:\Users\MYUSER\AppData\Local\Programs\Python\Python313\python.exe
if it's not listed, click"Enter interpreter path" and manually navigate to:
Once you’ve selected the correct interpreter:
Restart VS Code (optional but recommended)
Check your terminal (bottom of VS Code), it should now use the correct environment
Try running your .py script again
In your Python script, add:
import discord
print(discord._version_)
Then run it:
python yourscript.py
If everything is correct, it should print:
2.5.2
Here’s what you can do:
Go to settings.json (Ctrl+Shift+P> "Preferences: Open Settings (JSON)") and make sure there is no incorrect pythonPath setting.
Reinstall Pylance if needed:
pip install pylance
Or reload VS Code's language server: