r/learnpython • u/anas_mv • Oct 23 '26
Python doesn't work in vc
I just want to
print("hello, world")
and it doesn't work
3
u/eruciform Oct 23 '26
where did you type it, how did you run it, and what message did you get, there's nowhere near enough information to debug this as is
-1
u/anas_mv Oct 23 '26
In the terminalIn the terminal, i write python hello , i got C:\Users\tec\AppData\Local\Python\pythoncore-3.15-64\python.exe: can't open file 'C:\Users\hello.py': [Errno 2] No such file or directory
3
u/eruciform Oct 23 '26
hello.py is not in your current directory of C:\Users\ so it can't find it
either move/save it there or change directory to where your hello.py is and rerun it there
0
u/anas_mv Oct 23 '26
How
2
u/eruciform Oct 23 '26
when you save the file you have to choose where it goes
or on the command line utilize "cd" (change directory) to change where you are
if you can't do either then you need to look up some tutorials on the tool you're using to save or on the command line terminal that you're using
1
u/JGhostThing Oct 23 '26
You need to be in the directory where the file hello.py is. Then "python hello" should work.
2
u/Outside_Complaint755 Oct 23 '26
When you invoke Python and tell it to run a script, you need to provide either the correct relative path to the script from your current working directory, or a full absolute path.
Let's say the script hello.py is in C:\Users\Me\Scripts\Test\hello.py
And let's say that when you launch the terminal, it opens to C:\Users\Me\ by default.
Then to run your script you can do one of the following:
# Option 1 - absolute path
Users\Me> python "C:\Users\Me\Scripts\Test\hello.py"
# Option 2 - relative path
Users\Me> python "Scripts\Test\hello.py"
# Option 3 - change working directory
# Then use new relative path
Users\Me> cd Scripts\Test
Users\Me\Scripts\Test> python hello.py1
1
u/samuraisammich Oct 23 '26
Save the file first (there should be no dot next to the tab title at the top if the content of the file is saved)
1
u/ConcreteExist Oct 23 '26
So when you want to run a file with a program like python, you need to give it the actual path to the file.
1
u/andrewgarcia88 Oct 25 '26
double check the file is actually saved with a a .py extension and the quotes around hello world are straight quotes not curly ones, some editors autocorrect quotes which breaks the syntax
0
u/OlenaDoubleChecks Oct 23 '26
"vc" as in VS Code? Probably the interpreter isn't selected or Python isn't on PATH. What error do you get when you run it, and are you hitting the run button or typing in the terminal?
5
u/Friendly-Repeat4854 Oct 23 '26
What Error Message did you receive ?
My Guess is your Python Interpreter propably isnt the correct one.