Sublime Forum

Help with Python build in sublime I'm new and hopeless

#1

So I got sublime configured for Python 3.8 and I am running windows 10. I know the Sublime IDE is working (partly) because it recognizes my Python commands. My big issue is that whether I do CTRL + SHIFT+ B or CTRL+ B, all the console says is… “building” then poof. Nothing happens. I also have some [WIN ERROR 2].

Please, can someone help me? I have gone as far as I can on my own at this point and I do not want to lose my motivation in honing my software skills.

Below is a picture of what I am seeing on my end.

**I am a new User so I can only post one image, here’s what the rest of my console says:

[WinError 2] The system cannot find the file specified
[cmd: [‘C:\Users\Osa Iyamu\AppData\Local\Programs\Python\Python38\pytho.exe’, ‘-i’, ‘-u’, ‘C:\Users\Osa Iyamu\Desktop\test.py’]]
[dir: C:\Users\Osa Iyamu\Desktop]
[path: C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client;C:\Program Files\Intel\iCLS Client;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Program Files\Java\jdk 8\bin;C:\Program Files\Java\jre 8\bin;C:\Program Files\Intel\Intel® Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel® Management Engine Components\DAL;C:\Program Files\Intel\Intel® Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel® Management Engine Components\IPT;C:\Program Files (x86)\Skype\Phone;C:\Program Files\MATLAB\MATLAB Production Server\R2015a\runtime\win64;C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin;C:\Program Files\MATLAB\MATLAB Production Server\R2015a\polyspace\bin;C:\WINDOWS\system32\config\systemprofile.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit;C:\Program Files\Microsoft SQL Server\130\Tools\Binn;C:\Program Files (x86)\nodejs;C:\Program Files\Git\cmd;C:\WINDOWS\System32\OpenSSH;C:\Program Files\Intel\WiFi\bin;C:\Program Files\Common Files\Intel\WirelessCommon;C:\Users\Osa Iyamu\AppData\Local\Programs\Python\Python38\Scripts;C:\Users\Osa Iyamu\AppData\Local\Programs\Python\Python38;C:\Users\Osa Iyamu\AppData\Roaming\npm;C:\Users\Osa Iyamu\AppData\Local\Microsoft\WindowsApps;]
[Finished] **

0 Likes

#2

pytho.exe ???

0 Likes

#3

Thanks for pointing that out. What is even more interesting is that I selected the original python build that was present with Sublime 3 this time and the code executed.

The reason I made the new build was because the initial one wasn’t working. I don’t really understand the solution that came about but, I’ll work with it.

I will also fix what you mentioned thank you.

0 Likes

#4

ST reads the environment variables upon startup and uses %PATH% to look for executables like python.exe if they are called without path - as the normal shell would do.

If you installed python after opening ST, the environment variables may have not been up to date.

0 Likes

#5

You can set up custom build information, and when you use CTRL + B ( which may or may not be the default ) it will access your selected build on a per language basis.

Look under: Tools > Build System and see what you have selected.

The file should be blahblahblah.sublime-build where blahblahblah is what appears in the menu. So, if you have everything installed ( the best solution to search your computer drives instantly after indexing the first time and keeping up to date; it’s best to keep it running 24/7 - and turn off indexing within Windows as that system is terrible )…

For instance, mine is PythonCompiler, which I did a search for and it is in %appdata%\Sublime Text 3\Packages\User\PythonCompiler.sublime-build

{
	"cmd":
	[
							"py",
							"-u",
							"$file",
	],
	"file_regex":			"^[ ]*File \"(...*?)\", line ([0-9]*)",
	"selector":				"source.python",
	// "env":
	// {
	// 	// "PYTHONPATH":	"/Users/Acecool/Documents/Scripts"
	// 	"PYTHONPATH":		"C:/Program Files/Sublime Text 3",
	// },
	// "working_dir":		"C:/Program Files/Sublime Text 3",
	// "working_dir":			"${project_path:${folder}}",
	"path":				"C:/Program Files/Sublime Text 3;C:/Program Files (x86)/Common Files/Oracle/Java/javapath;C:/Program Files/Microsoft MPI/Bin/;C:/ProgramData/Oracle/Java/javapath;C:/Windows/system32;C:/Windows;C:/Windows/System32/Wbem;C:/Windows/System32/WindowsPowerShell/v1.0/;C:/WINDOWS/system32;C:/WINDOWS;C:/WINDOWS/System32/Wbem;C:/WINDOWS/System32/WindowsPowerShell/v1.0/;C:/Program Files (x86)/NVIDIA Corporation/PhysX/Common;c:/Program Files (x86)/Microsoft SQL Server/90/Tools/binn/;C:/Program Files/Microsoft SQL Server/130/Tools/Binn/;C:/Program Files/dotnet/;C:/WINDOWS/system32;C:/WINDOWS;C:/WINDOWS/System32/Wbem;C:/WINDOWS/System32/WindowsPowerShell/v1.0/;C:/Program Files (x86)/GtkSharp/2.12/bin;C:/Program Files/Git/cmd;C:/Program Files/nodejs/;C:/Program Files (x86)/GNU Tools ARM Embedded/5.4 2016q3/bin;C:/Users/Acecool/AppData/Local/Microsoft/WindowsApps;C:/Users/Acecool/AppData/Local/atom/bin;C:/Program Files/Microsoft VS Code/bin;C:/Users/Acecool/AppData/Roaming/npm;%USERPROFILE%/AppData/Local/Microsoft/WindowsApps;",
}

which works for me.

Also, if you press CTRL + B and it says building, and then nothing on screen - that can be a good sign.

If you get errors, you’ll have errors output. If you have print statements in your code, then you’ll see that.

If you build something like

def blah( ):
  print( 'test' );

then nothing will happen. However, if you build this:

def blah( ):
  print( 'test' );
blah( );

then you’ll have this output to your console:

test
[Finished in 0.1s]

As long as it is a .py file…

If you just create a new blank file and do the same thing, you’ll end up with:

C:\AcecoolLibraries\VisualStudioLibrary\Shared\Python36_64\python.exe: can't find '__main__' module in ''
[Finished in 0.1s with exit code 1]
[cmd: ['py', '-u', '']]
[dir: C:\Users\Acecool\AppData\Roaming\Sublime Text 3\Packages\User]
[path: C:\Program Files\Microsoft MPI\Bin\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\IncrediBuild;C:\Program Files\Git\cmd;C:\Program Files (x86)\Microsoft Emulator Manager\1.0\;C:\Users\Acecool\AppData\Local\Microsoft\WindowsApps;C:\Users\Acecool\AppData\Local\atom\bin;C:\Users\Acecool\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\Acecool\AppData\Local\GitHubDesktop\bin;%USERPROFILE%\AppData\Local\Microsoft\WindowsApps;]

Which means it can not find a function main ( which is a default magic function for packages in Python… ie: If you run a python package, such as math, and it has a main function in it, then it’ll use that… otherwise it would just compile as most packages do not execute anything but are basic libraries / packages… However, you can include a main function in a package / library in order to show examples of code )…

Now, the other issue is the file isn’t SAVED. The build system in Sublime Text, as far as I know, will RUN an external program / command… It’ll pass in the filename as an argument.

If your file has no name, it’ll pass in ‘’ ( ie: an empty string ).

So…

Since you have named it test.py, it will pass in C:\full\path\to\test.py to your python…

However, the build file may not be set up properly.

1 Like