VS Code keeps saying there is not such file when I try to run my code

Question:

I am new to the world of coding, which means I’m new to VS Code. Currently I’m self learning Python and typed in some code in VS Code to make sure I really understand what was going on (OOP if any of you are interested, class and instance attribute killed my dum dum brain, I understand it now tho).

However, when I typed in python name.py in the terminal, it keeps on saying that “There is no such file or directory” even though I have the file opened.

Can someone explain what is going on? Thanks

Edit: I have found the problem, I was running my code in Powershell which I guess it is opened by default? Anyways, it couldn’t find my file there and thus it keeps on saying that the file doesn’t exist. I fixed it by creating a folder in desktop and making a file in the folder, then in the Explorer I right clicked the file and ran it successfully.

Asked By: Blueyu

||

Answers:

It is most likely going to be due to an altered name of a file so when running the console is searching for a file that is no longer there (I often get this error when this has happened).
However, it could also be due to the terminal not being in the current directory where said file is placed.
If it is the first one just change the file back to the name it states in your console and your issue should be resolved.

Answered By: joeca
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.