Sublime Forum

WinError 2 in new Sublime Text 4

#1

I used Sublime Text 3 before and everything worked well. After updating it to Sublime Text 4, I found it cannot run python scripts anymore.
By clicking Ctrl+B in a python script, I get this output every time:

[WinError 2] The system cannot find the file specified.
[cmd: ['py', '-u', 'C:\\Users\\Hsin\\Desktop\\tkinter-test.py']]
[dir: C:\Users\Hsin\Desktop]
[path: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\libnvvp;D:\Software\NetSarang\Xshell 6\;D:\Software\NetSarang\Xftp 6\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;D:\Software\Git\cmd;D:\Software\MATLAB\R2019b\bin;D:\Software\Adams\Adams_Student_Edition\2020\bin;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;D:\Software\Miniconda3;D:\Software\Miniconda3\Library\mingw-w64\bin;D:\Software\Miniconda3\Library\usr\bin;D:\Software\Miniconda3\Library\bin;D:\Software\Miniconda3\Scripts;C:\Users\Hsin\AppData\Local\Microsoft\WindowsApps;D:\Libraries\ffmpeg\bin;C:\Users\Hsin\AppData\Local\GitHubDesktop\bin;;%USERPROFILE%\AppData\Local\Microsoft\WindowsApps]
[Finished]

I notice the command actually sends ‘py’ instead of ‘python’, which makes it cracked down. In the default configuration file Python.sublime-package, I confirmed this issue:

{
	"cmd": ["python3", "-u", "$file"],
	"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
	"selector": "source.python",

	"env": {"PYTHONIOENCODING": "utf-8"},

	"windows": {
		"cmd": ["py", "-u", "$file"],
	},

	"variants":
	[
		{
			"name": "Syntax Check",
			"cmd": ["python3", "-m", "py_compile", "$file"],

			"windows": {
				"cmd": ["py", "-m", "py_compile", "$file"],
			}
		}
	]
}

Now that I do use Windows operating system, so the software chooses a ‘py’ and leads to a cracking down.
I am confused why in this situation a ‘py’ is added along with ‘python’. I checked Sublime Text 3, and there was no such distinction, only a ‘python’ there. Is this a bug for windows users?

0 Likes

New user - [WinError 2] The system cannot find the file specified
[WinError 2] The system cannot find the file specified
#2

New forum users cannot post pictures above, so I add them here.

0 Likes

#3

0 Likes

#4

What version of Windows are you using?

0 Likes

#5

Windows 10 20H2.

0 Likes

#6

If you install a regular distribution of Python 3.9 then there should be a py.exe available in %PATH%.

0 Likes

#7

Thank you for your information!
I’m using python3.7 in miniconda, and I think there are many users like me who use old version python. They would have trouble when updating their Sublime. If possible, it would be better for Sublime to stop using ‘py’ and keep it ‘python’ for better robustness.

0 Likes

#8

I see you have these paths in your %PATH%:

D:\Software\Miniconda3\Library\mingw-w64\bin
D:\Software\Miniconda3\Library\usr\bin
D:\Software\Miniconda3\Library\bin
D:\Software\Miniconda3\Scripts

If you add a symbolic link in one of those directories from py.exe to wherever python.exe lives, things should work.

0 Likes

#9

The reason for using py.exe is explained in this git commit: https://github.com/sublimehq/Packages/commit/a97ecf3780489928fcbd5420177f0a7674a21a73

0 Likes

#10

This helps! It should be the problem of miniconda, not python version. Original python got ‘py’ as an entrance, yet this is missing in miniconda. I will try adding a symbolic link manually. Thank you very much!

0 Likes

#11

Symbolic link doesn’t help. It becomes py.exe.lnk as the full name in Windows and cmd cannot call it out just by py.
I instead simply copy and paste the python.exe file in the root directory to Miniconda3\Scripts and rename it as py.exe. Now it works finally.

All in all, I still hold the opinion that python is a more robust implementation than py for calling out python building lol.

1 Like