Sublime Forum

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

#1

I am very new to this and trying to run a simple hello world program but when build with python3 get the following error message. Any help would be much appreciated.

[WinError 2] The system cannot find the file specified
[cmd: [‘python3’, ‘-u’, ‘C:\Users\Darci\Desktop\python_work\hello_world.py’]]
[dir: C:\Users\Darci\Desktop\python_work]
[path: C:\Users\Darci\AppData\Local\Programs\Python\Python38-32;C:\Users\Darci\AppData\Local\Programs\Python\Python38-32\Scripts;C:\Users\Darci\AppData\Local\Programs\Python\Python38-32]
[Finished]

0 Likes

#2

A very common problem of new users.

As the error message says: The python3 command defined in the default build system for python can’t be found as it is not part of python windows releases by default.

The solution is to tweak the build system configuration as described in …

0 Likes

#3

Thank you. I updated the code and according to the book I’m following I should get…

Hello Python World!
Finished in 0.2s

However I just get Finished 0.2s - does that mean it is working, or not? Is there a way to check if it is working? Sorry for the basic questions

0 Likes

#4

If you’re using the built in Python build system (or a modification of it) make sure that you’re not selecting the Syntax Check variant of the build; that only compiles the code without running it.

0 Likes

#5

I changed the build system again to the following code and now when I try and run it it says that there is ‘no build system’.

And sorry, what do you mean @OdatNurd about selecting the syntax check in the editor? I have checked the build system in SE and can’t see this checked, or not.

0 Likes

#6

realised I didn’t put the code in - this is what I inputted

“cmd”: “python -u “$file””,
“file_regex”: “^ ]File “(…?)”, line ([0-9]*)”,
“selector”: “source.python”,

0 Likes

#7

If it says No build system then the file is broken in some fashion and Sublime can’t parse it. Without seeing your actual build it’s hard to say why. What you posted above is not a complete build system, for example. If you install PackageDev and then open the build file, it will syntax highlight and show you where the errors are.

That said, if python would work, then you don’t need a custom build system because Sublime ships with a Python.sublime-build that does the same thing. That build system has a variant named Syntax Check that only compiles the code without running it.

I would recommend setting the Tools > Build System item to Automatic, and then open a Python file and select Tools > Build With... from the menu. From the options you’re given, choose just Python (and not Python - Syntax Check) and see what happens.

1 Like

#8

Thank you @OdatNurd. I have changed the Build system to automatic. I then saved a new Python file, tried to run the simple Hello python World program again, selected python within build with. However when it runs I just get the ‘finished in 0.2s’ nothing else. So I assume this still isn’t working properly? Sorry for being such a nuisance…

0 Likes

#9

This book that you are reading for Python, does it use IDLE (the Python REPL), by chance? Because Sublime Text is not a REPL, so you will have to use the print() function in your code to see the result of your code. That is - print(“Hello World”).
Otherwise, you will get what you are seeing.
In case you are wondering, ST does not do input() by itself. You will need to use a package to do that.

0 Likes

#10
0 Likes

#11

@Jackeroo, not sure what IDLE is but I haven’t seen it referred to in the book. The book is Python Crash Course 2nd Edtn. I have been writing print("") but it just says finished so assume I am doing something else wrong?!

0 Likes

#12

@deathaxe I have no idea what Terminus is. In the book it just says that if I have downloaded most recent version of Python (and downloaded to PATH) I won’t need to configure it with ST but it doesn’t seem to be the case

0 Likes

#13

You need to use my example. If you are coding what you write you are coding, you are printing nothing. A copy of your code would have been useful so we don’t have to play Twenty Questions here.
Stay away from Terminus until you have mastered Python basics.

0 Likes

#14

The code i’m writing in ST is: print(“Hello Python World!”) as per the example in the book. I have saved the file as hello_world.py in a python folder I’ve created on my desktop. I have tried to build this as python, python 3 and automatic. When build it just says Finished in 0.2s, not the print and time.

0 Likes

#15

Break your code (say by removing the last ) character) and then run the build again and paste the error diagnostic information from the output panel here.

0 Likes

#16

That’s the thing, if I type print(“Hello Python World” [removing )] I don’t get an error, i still just get Finished 0.2 seconds

0 Likes

Beginner syntax errors while teaching myself Python3
#17

Well then, whatever it’s doing, it’s not executing your Python code at all. I would double check that you’re definitely selecting Python when you’re being asked.

Something to try would be to use Tools > Build System > New Build System from the menu, which will open up a stub build system. Replace the entire content of that file with this:

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

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

	"variants":
	[
		{
			"name": "Syntax Check",
			"shell_cmd": "python -m py_compile \"${file}\"",
		}
	]
}

Save the file in the location that Sublime will default to, and name it something really obvious, like I am definitely python.sublime-build.

Once you do that, either set the build system to Automatic and choose Tools > Build With and select the build with this name, or select it directly from the menu. Then use that to build your program and see what happens.

2 Likes

#18

Thank you. I have done exactly that and I am still getting ‘finished in 0.2s’. I did read on one of these feeds that Windows requires a double \, should I try that with the above as it appears still not to be working?!

0 Likes

#19

The above build system will work on any system regardless of what OS it is; it only requires that you’ve installed Python.

At this point, without seeing exactly the code that you’re trying to build and some screenshots or a screencast of how you’re attempting to run the thing, it’s hard to say what might be going wrong for you here.

0 Likes

#20

The code I’m trying to run is really simple - its print(“Hello Python World!”) after saving a file in a python work folder on my desktop called hello_world.py and building it with the new build system as per your earlier message. When i build it it just says finished in 0.2s. I really have no idea. I’ve installed Python 3.8 (32-bit)

0 Likes