Sublime Forum

Rookie Question Python and sublime text


I am just starting out learning python the book I am using is having me use sublime text as the text editor. Originally I was running windows 11 and everything worked great, but I reverted to windows 10 for a cyber security class I am taking. Here is ther error code

[WinError 2] The system cannot find the file specified
[cmd: [‘python3’, ‘-u’, ‘’]]
[dir: C:\Program Files\Sublime Text]
[path: C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Users\JohnC\AppData\Local\Programs\Python\Python310\Scripts;C:\Users\JohnC\AppData\Local\Programs\Python\Python310;C:\Users\JohnC\AppData\Local\Microsoft\WindowsApps;]



You need to save the file (with .py extension).



I did that, it was an instruction in the book. When I took the same steps in Windows 11 it worked, and was playing with variables and strings. When I reverted to Windows 10 the same steps got different results.



This part of the diagnostic is showing you what command was executed, python3 with an argument of -u and a filename of '' . That filename is empty, so that’s an indication that you didn’t save your file to disk first as mentioned above. If you don’t save the file to disk, the external Python process can’t find it.



Thank you for your response
file name was entered as “$file” it was saved to the default directory I can check and see if there was some error in my code (I check it over and over), I think there is something going on where it is not recognizing the file but I don’t think it is the command. From memory hopefully with out error what I typed was (hopefully my memory is correct I left the book at home

[“cmd”] : [“Python3”, “-u”, “$file”],

I did complete this sucessfully prior to reverting to Windows 10 y using 11



Without seeing your build system itself (if you have created a custom one) it’s hard to say what you might have going wrong, but the diagnostic shows you what was executed and not what the build system contains.

So the build might say "cmd": ["python", "-u", "$file"] meaning “execute the program named Python on the current file”. If the diagnostic says $file then you have saved your file to disk with the name $file ; while that may technically work, you want your filenames to end in .py so that Sublime and your computer know that they’re Python files.



I will play with it a little after work