Directory not found

I am getting this error: `C:\Users\Anthony.DESKTOP-ES5HL78\AppData\Local\Programs\Python\Python310\python.exe: can’t open file ‘C:\Users\Anthony.DESKTOP-ES5HL78\’: [Errno 2] No such file or directory’

I am sure my directory is correct. What am I missing?

As the error plainly states, you are presumably missing the Python file in your user home directory that you attempted to run. Either you misspelled the name/path of the file when you invoked Python, or the file is not located where you think it is.

I’m not sure what else you expect us to tell you, sorry, given that was the only information you gave us.

@CAM-Gerlach I get the same error. I am doing a Python Course and I need to run it from the command line. But I get this error.

C:\Users\Legion 5\AppData\Local\Programs\Python\Python311\python.exe: can’t open file ‘c:\users\legion5\mypythonscripts\’: [Errno 2] No such file or directory

Even though I have the files right where it should be. I m a beginner, sorry if I don’t provide enough information for you, please let me know what else should I let you know.

It’s not where you think it is.

You’re saying that it’s:


but it’s really:

c:\users\legion 5\mypythonscripts\

Wait, I m more confused now than before. I don’t think I get get what you re saying. I just copy paste the error here.

But if I look closer, i see that the command is looking in another folder. From what I see above the PC is looking in C:\Users\Legion 5\AppData\Local\Programs\Python\Python311 instead of C:\Users\Legion 5\MyPythonScripts.

Is this what you re saying?

It can’t find




contains a space and:

c:\users\legion 5\mypythonscripts\


‘legion5’ (no space) is not the same as ‘legion 5’ (with space).

Fun shortcut in Explorer: if you click in the address bar (where it says “> This PC > Local Disk(C:) > etc”) and type cmd and press Enter, it will open a command prompt already navigated to that directory, so you don’t have to type a series of cd _ commands.

Ok, thanks I got that. But the error is the following C:\Users\Legion 5\AppData\Local\Programs\Python\Python311\python.exe: can’t open file ‘c:\users\legion5\mypythonscripts\’: [Errno 2] No such file or directory .From what I can see, it doest stop in “legion 5”(where the folder is) its gooing through in 'appdata\local…" and so on. Why is that.

Please also note that i tried with spaces, without spaces, with quotation mark and without…

Maybe i messed something up withput even knowing?

You have Python is installed in C:\Users\Legion 5\AppData\Local\Programs\Python\Python311. That’s because you have it installed for just you (your “Legion 5” user account) and not for “all users”, i.e. not for other user accounts.

You’re asking Python run c:\users\legion5\mypythonscripts\, but that’s not the correct path. The correct path is, presumably, c:\users\legion 5\mypythonscripts\

When you created the user account you called it “Legion 5” (with a space), but you’re omitting the space when giving the path. Hence, Python can’t find the file.

On Windows it’s recommended to use the “Python Launcher”, so to run the file:

py "c:\users\legion 5\mypythonscripts\"

Good evening!

I close my vsstudio, deleted my folder with files and created a new folder in users, this way:

“C:\Users\Matheus Neitzl\projeto\”

after, i passed the folder “projeto” manually to the “desktop”, when run the code is sucess.

PS: im brazilian, so, please, forgive my mistakes. :slight_smile:

Welcome! I’m not clear on what question you’re trying to ask here, sorry.

If you’re getting the same error as the OP, you need to be 100% sure the path you are passing to python is exactly the actual path to the Python script you’re trying to run—the easiest way to be sure is simply dragging and dropping the Python script file into the terminal window, which will automatically insert its exact path.

Otherwise, if you’re having a different issue, please open a new topic. Thanks, and best of luck!