r/learnpython • u/Zoneistaken • Sep 01 '25
How do I set up Python on VSCode?
Hi! I'm currently trying to use Python to create a discord bot to handle my suggestion forums but I keep running into the same problem. When I try to use "import discord" it outputs "ModuleNotFoundError: No module named 'discord'". I've tried to install discord in the terminal but it keeps givi me a bunch of "Requirement already satisfied" messages. How can I fix this?
[SOLVED!!]
12
u/ninhaomah Sep 01 '25
Here is a tip to ask and get help asap. Here and also in your school/working life.
Reduce English description whenever possible. Give the facts / steps.
"tried to install discord" ????
Copy and paste the commands you used or screenshot.
Don't say I can't go to the site. Say I get error 404. Big difference.
6
u/cylonlover Sep 02 '25
You are acting obtuse. It is quite obvious that OP is not installing discord, but the discord library, since they mention that requirements are already satisfied.
There is really very little unclear about OP's question:
Be using VSCode
Can't import library in Python script
Yet can't install library because already installed
What gives? Asks forum
The problem domain is one of the most common, environments, virtual or multiple Python versions, and having these kinds of problems when trying an advanced editor (as per F5 functionality) like VSCode is known for displaying the problems.
Well, that's just my opinion, I found it very easy to understand OP's predicament, and I found you not even having tried, but jumped the gun. Compared to 90% of the questions asked in this forum, this one was actually very considerate, and not at all calling for arrogance.
-30
u/Zoneistaken Sep 01 '25
Okay, but I never asked for this.
11
u/ninhaomah Sep 01 '25
What is "this" you are referring to ?
3
u/Langdon_St_Ives Sep 02 '25
The solid and quite inoffensive life advice you gave them. Some people are allergic to being told how to fish when all they asked for was a fish. Most of them don’t go very far.
6
u/rumpleforeskin83 Sep 01 '25
You asked for help, knowing how to ask exactly what you need help with is a big part of that. If people need to ask 20 follow up questions to know what you've done/not done and the actual issue, they'll just not bother generally.
3
u/Yetiani Sep 02 '25
this is solid advice on how to ask for help in the future, do it and don't complain
-9
u/Zoneistaken Sep 02 '25
Never meant this in a rude way so I have no idea why I come back and find people downvoting and talking back to me.
9
8
u/Itchy-Call-8727 Sep 01 '25
It is common practice to use a Python virtual environment for each project. The purpose is to separate project dependencies from one another. For example, installing Discord version 1.0.0 in project A, and when you get to project B, you install Discord, and a newer version is released, which would break project A, but project A has the older version locked down, and your project does not break. You use the newer version in project B and update A when you have the time.
That being said, you should create a Python virtual environment for your project if it has not already been done. You can use 'python -m venv venv' to create the environment in your project root. Then you can tell VSCode what Python virtual env to use by clicking on Python on the lower toolbar bar then selecting the relative Python binary, usually ./my-project/venv/bin/python3
To activate the virtual environment, though VSCode usually activates it automatically after selecting it and opening up a new terminal, you can use 'source venv/bin/activate'
I use Python often, and I usually create command aliases to create, activate, and end Python virtual environments to make the process easier.
Once you have the virtual environment activated in your terminal, run your pip install commands and then use 'pip freeze > requirements.txt' ' to create a requirements.txt file with your project's locked dependency versions.
1
u/jongscx Sep 01 '25
I assume you're running into this when you hit F5 to debug using the VScode debugger? Have you tried running your code directly in the terminal "python mycode.py"
0
u/SirBoboGargle Sep 02 '25
I recommend Cursor instead.
2
u/nekokattt Sep 02 '25
Hey, you might be able to help. I need to tighten the screw on my glasses. What construction company do you suggest I hire?
8
u/SirAwesome789 Sep 01 '25
You don't need to "setup" python in vscode, vscode is just a text editor
Idk what problem you're running into but you have multiple versions of python, you might be trying to install it on an older version then run it in a newer version that doesn't have it
Alternatively make sure you're installing the right thing, it's discord.py not just discord according to the docs