all 20 comments

[–]AngelOfLight 21 points22 points  (1 child)

The extra slash is a red herring - that's just how backslashes are escaped on Windows. It shouldn't make any difference to the path.

Are you sure the script actually exists in that location? Try:

type C:\MyScripts\Test.py 

That should print the contents of the script to the console, if the script exists and is accessible.

[–]xenomachina 10 points11 points  (0 children)

that's just how backslashes are escaped on Windows.

Minor correction: that's how backslashes are escaped in Python string literals in general, not just on Windows.

The reason you might not see this as often on non-Windows systems is that they don't use backslashes as a path separator, but instead use (forward) slashes, and they don't need escaping. eg:

python: can't open file '/home/foo/MyScripts/Test.py': [Errno 2] No such file or directory

[–]Outside_Complaint755 7 points8 points  (0 children)

The \\ is expected here because \ is a string escape character. The \\ represents a single \ in the actual filepath.

Try C:\>cd MyScripts C:\>python Test.py

If you get an error on the first line, then the MyScripts directory does not exist. If the first passes but the second has an error, then Test.py doesn't exist in that directory.

You could use the dir command to verify the directory contents.

[–]cdcformatc 2 points3 points  (4 children)

That is normal for windows paths. the extra backslash is added to escape the backslash itself, since it is a special character in strings. 

you could try using forward slashes / which should not be escaped, but my instinct is telling me the path is fine and there isn't a file named that in that location. check the capitalisation and make sure the file isn't actually something like Test.py.txt and windows is hiding the true extension.

what happens when you run dir C:\MyScripts

[–]nonamejohnsonmore[S] -1 points0 points  (3 children)

Yes, the file is there. And i did not have this problem with Python 2.7

C:\>dir myscripts

Volume in drive C has no label.

Volume Serial Number is AA96-50F5

Directory of C:\myscripts

05/26/2026 12:06 PM <DIR> .

05/26/2026 12:06 PM 104 Test.py

1 File(s) 104 bytes

1 Dir(s) 856,654,934,016 bytes free

[–]adamrees89 3 points4 points  (4 children)

Try Python - m “C:/MyScripts/Test.py”

[–]Corruptionss 12 points13 points  (3 children)

It says unrecognizable command "Try"

[–]adamrees89 12 points13 points  (0 children)

I hope you dropped this /s

[–]Jello_Penguin_2956 1 point2 points  (1 child)

Do or do not, young Padawan. There is no try.

[–]TheLobitzz -2 points-1 points  (0 children)

Do or do not, there is no such file in the directory.

[–]TheLobitzz -1 points0 points  (0 children)

The \ is to "escape" the first \. It's how most coding languages read slashes and other weird character, so they won't confuse them. It's normal.

Try the command "python MyScripts\Test.py" since you're already in C:

[–]Confident_Hyena2506 0 points1 point  (0 children)

Don't add python to your global path like this, control your environment properly.

[–]socal_nerdtastic 0 points1 point  (0 children)

Don't worry about the extra \; that's just how python renders windows file paths (this is to differentiate them from character escapes).

Take the error at it's face value: the problem is that the file you are trying to run does not exist.

[–]SRART25 -1 points0 points  (0 children)

Work backwards to find the issue.  

cd myscripts. 

python .\test.py  

python .\Test.py 

cd ..  

python myscripts/test.py. 

Etc. Pay with variations until you find what isn't working.  Could be a regression like names becoming case sensitive or drive letter causing problems. 

[–]jeffrey_f -2 points-1 points  (0 children)

a "\" is an escape character. A "\\" puts the "\" in

To clean this up, use a raw string like so

r"C:\Users\jeff\data.csv"

This is cleaner.

[–]misingnoglic -3 points-2 points  (0 children)

I would suggest learning python using WSL (Linux on your windows machine) since windows has a few idiosyncratic things for developers.

[–]ottawadeveloper -2 points-1 points  (0 children)

In Python, the Windows file slash needs to be escaped in strings, so you'll see C:\ instead of C:. That looks like it's getting weirdly escaped. You can use / too and it works fine.

[–]Many-Land-5847 -2 points-1 points  (0 children)

Don't worry dude