Sublime Forum

WinError 2,THE SYSTEM CANNOT FIND FILE SPECIFIED

#1

I had to reload a fresh version of windows 10 on my PC, after I did I lost Python & Sublime Text, so I loaded them both again.
Now when I do, in Sublime Text, TOOLS / BUILD I get an error in the Sublime Text lower Window saying WinError 2 . . . THE SYSTEM CANNOT FIND THE FILE SPECIFIED.
A file does show and it looks right but has “added stuff” in it that I don’t see in the actual file where Python is located.
It seems Sublime can’t find Python ???
What’s wrong ???

Al

0 Likes

#2

How about a search? https://forum.sublimetext.com/search?q=WinError

This question is asked every 2nd day and answered thousands of times already.

0 Likes

#3

Thanks for the info, I did try a number of the things listed, none work. At one point, yesterday the whole thing worked, I didn’t do anything to it, it just started working. This morning I turned on the PC, went to do something with Python & Sublime and again got the WinError 2.
You mentioned in one of the many suggestions from you & others . . . to correct the problem the use of Anacondo vs Windows. I tried your suggestion of putting in that long command, to favor me as a Window user . . . it stopped the WinError 2 but I can’t get anything out of sublime text . . . for example if I try the simple Print - Hello Python world! . . . I just get the info on how long it took to complete . . . no seeing Hello Python world ! in the bottom window.
Again thanks for your help & time.
Al

0 Likes

#4

Don’t pick the Python - Syntax Check option when presented with a build, only Python; the syntax check variant only checks syntax, it doesn’t run anything. So you don’t see any output unless your program is broken.

0 Likes

#5

I tried your suggestion, did nothing, same results, shows time it took and that is all.
Does this in SYNTAX or just Python way.
Sorry for the questions but I’m new at this and trying to learn, as I said this worked flawlessly ( Python & Sublime Text ) for the last 6 months until I put a fresh version of Windows 10 in afew weeks ago . . . every other program I use works OK, including ones I had to reload after the Windows 10 refresh, only Sublime Text doesn’t work.
I am using the book Python Crash Course and the way the author says to load the cmd line worked before , now it does not.
Al

0 Likes

#6

In order to diagnose the problem, we will need to see the full output of the build panel when an error happens, also when it “suceeds” as above, the contents of a small simple program that should work and doesn’t, and the contents of the sublime-build file that you’re using

Specifically, if you’re following a book then I would assume that it specifically told you to create your own sublime-build file and not to use the one that’s built in; if so, without seeing what it contains it’s hard to say what could be going wrong.

0 Likes

#8

I got a question that might be my real issue . . . where exactly should the Python3.10.1.sublime-build file be located ?
The book says it should go into the default directory that opens when I open SAVE in Sublime Text.
But should it not go into a specific directory ??? Also what SAVE AS TYPE should it be? Like I said this worked before the fresh Windows install, and I recall that the build file went where Sublime wanted it to go.
Also it seems Python is being installed as an APP, in a file called APPDATA and SUBLIME as a PROGRAM FILE , does that make a difference?
Thank You.

Al

0 Likes

#9

The extension on the file has to be .sublime-build or Sublime won’t know that it’s supposed to be a build file. It also has to be contained anywhere within a Package, generally your User package would be where you would put it unless you’re a package author.

To find that location, Preferences: Browse Packages in the command palette or from the menu; in the window that opens up, the folder named User is the one you want. Anywhere inside of that folder is fine, should you want to keep things in some structure.

It will appear in the Tools > Build System menu with the name you gave the file, so if the file is named MyCoolBuild.sublime-build, it will appear as MyCoolBuild in the menu.

Should you want to create your own build system for Python it’s thus important to give the file a name like My Python.sublime-build or Custom Python.sublime-build or similar because if you just name it Pythons.sublime-build there will be two entries in the menu, the one that ships with Sublime and yours, and distinguishing them would be problematic.

The location of the install doesn’t really matter for your case here, the only important thing is that Sublime knows where to find it when the time comes (which is where things like the PATH and so on come into play).

All else being equal, unlike previous versions of Sublime, in Sublime Text 4 so long as you have installed a “normal” version of Python (that is, not Anacona or Miniconda or similar) and you didn’t go out of your way in the Python installer to turn off default options, the Python.sublime-build that ships with ST4 will work out of the box for anyone on Windows, Linux or MacOS that wants to execute Python 3 code unless you need very specific command line arguments, options, or other setup.

As such, depending on what you’re trying to do or when the book was written that you’re following, it’s entirely likely that it’s telling you to take a step that you don’t actually need to take and it’s just making things more complicated than it needs to be. A verification of that would be to create a file such as:

import sys
print(sys.version)

Save it on your Desktop as hello.py, then use Tools > Build With..., and select the build labeled Python (not Python - Check Syntax) and see if the code executes and prints the version of Python you expect.

0 Likes

#10

Got it going, finally. But as I said the books method no longer works . . . the author used
“cmd” : [“Python3.10.1”, “-u”, “$file”], . . . it no longer works.
I put in your program that is much longer, the one you posted . . . and setup eveything fresh, this time it works !!!
What I think might have been an issue too is this, I cleared out ( manually ) EVERYTHING on my PC that had anything to do with Python or Sublime Text . . . there was stuff where it it shouldn’t have been, like afew sublime-build files. That was most likely my fault. These were showing even after I uninstalled Python & Sublime Text.
Then I tried the books method that did work back in July,2021 but this time, no good. Then I used your method . . . it worked, giving me the output I wanted after using PRINT . . . not just how much time it took.
What might have been happening is when I tried it, the program was using a "messed up stray " sublime-build file, rather then the one I just setup . . . is that possible?
Question . . . when I uninstalled Python & Sublime Text should it have looked everywhere on my PC and took out everything that was Python & Sublime Text related . . . or it doesn’t work that way ???
Thank You again,
Al

2 Likes

#11

Sublime Text follows the rule that most applications do in that when you uninstall it, it only removes files that it put in place; so it will remove the application itself, any OS integrations, etc, but it does not remove any of your configuration or customization information. That’s a safety measure because if you were trying to upgrade for example, you don’t want all of your hard work clobbered.

So all else being equal, despite how frequently people tend to think the first solution to any problem is to uninstall and reinstall the application to see if that fixes things, more often than not this doesn’t actually solve anything at all; to fully reset Sublime as if you had just installed it for the first time, there are instructions for reverting Sublime Text to a freshly installed state.

As such, it is indeed possible that you were inadvertently using an older sublime-build file. In fact that might still be the case based on this:

In order to stop a build from telling you how long it took, the sublime-build file needs to be modified to include the quiet argument to tell it not to. So, if it’s not showing you the execution time, there’s still a modified build being used.

0 Likes