Sublime Forum

Build of python code not showing output

#1

Hello,
I hope this isn’t a stupid question/issue, newbie to sublime.
this was all working yesterday and now if I run the following simple python code (file is test1.py)
print(‘Hello’)

I get
Hello
execution time

if I add a second print line, as follows:
print(‘Hello’)
print(‘Goodbye’)
I only get the execution time, no print, anything more than 1 line shows just the execution time. Even if i add blank lines after the print

I was running some code and it was working and then…it stopped working so I ran these simple examples to illustrate the issue.

If I run the simple example using command line, it works
I am running sublime on windows 11
I uninstalled and reinstalled several times.
I’ve removed all packages and started fresh

Before I clicked create topic below, I tried it again and now 2 lines of code works
print(‘hello’)
print(‘goodbye’)

and the following does not
print(‘hello’)
print(‘goodbye’)
print(‘now’)

any thoughts?
thank you
Carmine

0 Likes

#2

A common mistake I have seen people having trouble with getting output in the build window is because they are picking the second option in the build selection panel i.e. Python - Syntax Check instead of Python. If you pick that option and continue to use ctrl + b to build, it’s not going to print anything because that doesn’t run the program.

1 Like

#3

Hello and thank you for the reply.
I wish my problem were that simple.

It’s extremely strange, I figure i have an environment variable out of whack somewhere…cause uninstalling and reinstalling does not solve my problem.

I am doing Build with and selecting python at times and other times just using CTRL B
Results are the same
1 print line it prints
2 print lines…just execution time

Save all on build set to true.

Code prints properly in terminal mode in windows, using
python test1.py

A quick update:
Unistalled Sublime
Reinstalled Sublime
Uninstalled Python
Reinstalled python

Test.py program:
print(‘hello’)

CTRL B
this will print hello and show execution time
change hello to good:
print(‘good’)
CTRL B
this will only shows execution time
change back to hello
print(‘hello’)
CTRL B
this will print hello and show execution time
remove the o from hello
print(‘hell’)
CTRL B
this will only show execution time
Appreciate the help

0 Likes

#4

Rather than describing it out, maybe a GIF/video of the process might throw some light.

0 Likes

#5

Attached are 2 images.
Please note i clicked CTRL B to execute both
Im a new user, 1 jpeg at a time :slight_smile:
this is the image with 1 line hello

0 Likes

#6

second image

0 Likes

#7

Does it happen in safe mode?

0 Likes

#8

In safe mode, nothing gets printed, not even with one print(‘hello’) statement.
And I did the save of the file with py extension and I confirm to build with python.
And i confirm that it runs in terminal mode using python hellotest.py

restart sublime without safe mode and get the same. Print does nothing but show execution time/

0 Likes

#9

Unfortunately I can’t reproduce this even in normal mode, print("Hello") gets printed, so does print("Hell")

In safe mode, nothing gets printed, not even with one print(‘hello’) statement.
And I did the save of the file with py extension and I confirm to build with python.
And i confirm that it runs in terminal mode using python hellotest.py

Honestly, if you have done all this, then I don’t see why it won’t print.

What Build of Sublime Text are you running and what operating system ?

0 Likes

#10

I’m running build 4126 on windows 11
I have to say it’s flippin weird, it was working then it stopped.

Thanks for the help

0 Likes

#11

Hello,
It seems to be working now.
Was watching the video on build systems.
Noticed I do not have a python package folder shown in first, second and 3rd images
when i try the install package I do see Python/Python sublime build, if it were installed properly i assume I would have the folder. Also, does anyone know why my packages are in Roaming instead of Local. Under local i have 3 folders for sublime text(image), these folders have cache and index folders inside…nothing else.
I did the following and it seems to work
Installed Python3 Package
Installed MagicPython
Disable Python package as per magic Python instruction
On the build menu I have Python and Python3 options
have to select Python, Python 3 does not seems to give build options of checking or running




Local%20Folder

I think i am going to have to clean up my machine to get things to run properly :slight_smile:

0 Likes

#12

You’re not supposed to have Python folders appearing anywhere inside of the Packages folder; those are only present if for some reason you’re overriding resources from the package that ships with Sublime. There are other places that packages are installed as well other than the place that you’re pointing out here.

Similarly there would not be a Python3.sublime-build file unless you created one yourself or something else created it for you, so the fact that it’s not there is not a worry.

The main reason for needing a Python3.sublime-build file is that on some operating systems there are two versions of Python installed, and the Python.sublime-build file executes just python, which on those systems is generally Python 2 and not Python 3. So a custom build is required to make it invoke python3 instead.

This is not an issue on Windows, where there is no version of Python installed other than the one that you install yourself (assuming that you do); on that system the Python.sublime-build file should Just Work ™ assuming that Python has been installed correctly.

In Sublime Text 4, which it appears you’re using, the default Python.sublime-build file has been augmented on Windows to work better for people as well.

Your problem sounds like a possible symptom of wanting to use Sublime for Python development and following potentially ill advised, old or outdated instructions on a blog post somewhere; Python should work out of the box for syntax highlighting and running code without requiring any third party packages at all.

0 Likes

#13

Thanks for the reply, appreciate it.
Not sure why it didn’t work in safe mode then.
Anyways I got it to work and i will clean my PC and reinstall at a later date.

0 Likes

#14

I’ve unistalled sublime.
I cleaned up my machine
Reinstalled sublime
Print still does NOT work.
No packages installed…vanilla install.

As an FYI, I can’t believe i can’t get this to work propoerly
Uninstalled Sublime
Uninstalled Python and everything around it.
Cleaned up every folder i could find on my C drive
deleted environment variables associated with both
Cleaned up the windows registry
Did restarts of window (3-4 times) to be sure things were still workiing

Reinstalled python and sublime.

Still the same thing
python test1.py in a terminal windows, works
image
In sublime, it does not work
image

In sublime with 1 Hello, it works
image

change Hello to Hell, it does not work
image

0 Likes

#15

Hello, The problem persists.
Take a look below ate everything I did to get this cleaned.
My current installation is sublime text vanilla
also, safe mode does not work either

0 Likes

#16

Just looking at the screenshots, it looks like you’re using PowerShell to execute the CLI version - I don’t know if that’s the same shell used by default by the build system or not and whether aspects of the executable path are shared between each.

And in the old screenshots, the failing screenshot “second image” states “Build finished” in the status bar, whereas the working version “Attached are 2 images…” doesn’t have this message.

I don’t know if either indicates somewhere to dig (and I don’t use Python or the build system)

0 Likes

#17

The long execution time is suspicious. Perhaps you have an antivirus or similar software interfering?

0 Likes

#18

hello
thanks for pointing me in the right direction
COMODO, my antivirus, is blocking the execution of my python programs in sublime.
The containment policy would prevent the execution of some python programs.
This is why 1 line of print(‘hello world’) works and multiple lines did not work.

I will make the necessary changes to the containment policy in COMODO and post back.

Thanks again!

I had to remove Comodo altogether, their containment policy implementation does NOT work properly.
Really appreciate the help, thanks again.

0 Likes