Sublime Forum

[Solved] Change py to python?

#1

I build a simple program on a Win10 laptop in Sublime and get:
[WinError 2] The system cannot find the file specified
[cmd: [‘py’, ‘-u’, ‘C:\learning_python\hello_world.py’]]
[dir: C:\learning_python]
[path: C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Anaconda3;C:\Anaconda3\Library\mingw-w64\bin;C:\Anaconda3\Library\usr\bin;C:\Anaconda3\Library\bin;C:\Anaconda3\Scripts;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\PROGRA~2\COMMON~1\Odbc\FILEMA~1;C:\Users\joan_\AppData\Local\Microsoft\WindowsApps;]
[Finished]

If I do the command py -u C:\learning_python\hello_world.py
I get the message that py is not recognized.
If I change py to python,
python -u C:\learning_python\hello_world.py
That works. Where is Sublime setting py as the language and how do I change it to python?

0 Likes

WinError2: The system cannot find the file specified
#2

The default build system for Python is in Python/Python.sublime-build, which you can view by using View Package File from the command palette.

It uses py on Windows and python3 everywhere else because on Windows, the Python installation puts a py.exe helper program into a location that’s always available on the system PATH, which makes it easier to run Python programs.

If you don’t have that for some reason, use the above command to see what the default build looks like, then use Tools > Build System > New Build System..., replace the template contents with the default build, alter it as needed, and save it in the location that Sublime will default to as something like Custom Python.sublime-build or similar.

When you build, you’ll be asked to choose which build to use; pick the one with the same name as the name you gave the file when you saved it.

0 Likes

#3

Thank you for the assistance. Unfortunately, I’m still having trouble. View Package File seems to be showing me empty files. I tried hunting for py.exe, and can’t find that, although I find python.exe and python3.exe. Python works fine. I think there is an implementation or setup issue somewhere - and I have Python 3.7, 3.8, 3.9, 3.10 among 2 different computers (not all on one!) I’m going to back up one of them, scrape everything off related to python, and install 3.11 and re-install Sublime. And watch some tutorials while that is in progress.
I am a python learner, experienced programmer but old school stuff. So if my questions sound like I don’t know what I am doing, yeah, that’s right!
JBD

0 Likes

#4

I fixed it!
I updated to Python 3.11, being sure to check the allow python on PATH box and, when it came up, allow longer PATH entries.
Why Sublime stopped working for me and why reinstalling Python fixed the problem is a mystery to me.

0 Likes