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.