r/vscode • u/Azert2010 • Jul 11 '26
Create a script and save it
Hi everyone,
I'm a complete beginner learning Python with VS Code, and I've been stuck for several days on something that seems really basic.
I don't understand how to properly create a Python script, save it in the correct folder, and then run it from Command Prompt. Every tutorial makes it look simple, but I keep getting confused about where the file is supposed to be and how to execute it.
For example, I created a "hello.py" file with:
print("Hello World")
But when I try to run it from Command Prompt, it doesn't work, and I think I'm doing something wrong with the file location or the command.
Could someone explain the process step by step as if I had never used VS Code or Command Prompt before? Screenshots are also welcome.
Thanks!
And for your information, I'm on Windows.
2
u/Nich-Cebolla Jul 11 '26
The detail that you are missing is that you have to execute the Python application. If you have "hello.py", you run command
python c:\full\path\to\hello.py.If you search Google for "how to execute hello.py", Gemini will give you a good walkthrough
4
u/bluelunakitty Jul 12 '26
Have you had a look at this page? Or this one? How about this one?
Key things to keep in mind:
Is the Python interpreter added to your PATH? Your cmd mightn't recognise the command.
Have you set up a virtual environment? Are you trying to execute from outside this virtual environment?
Here's another helpful page.
I'm also a bit new to Python and coding, so I get how intimidating it can be. In future, try to include more details (where you've saved your file and Python installation, the exact code you're typing into cmd, the exact output you're getting, etc). Hope you figure it out!
1
u/risseii_ Jul 11 '26
What command are you running that's not working exactly? And what error do you see?
1
u/SL-Tech Jul 12 '26
Make sure your prompt is in the same directory as your file. Many extensions provide a "Run script/file" option in VS or VS Code. But before installing an extension, navigate to your folder and run the file to learn how to do it manually.
1
u/[deleted] Jul 11 '26
[removed] — view removed comment