# Script Console print() not working

**URL:** <https://forum.inductiveautomation.com/t/script-console-print-not-working/51308>\
**Category:** Ignition\
**Tags:** ignition81, scripting\
**Created:** [September 24, 2021, 12:54pm UTC](https://forum.inductiveautomation.com/t/script-console-print-not-working/51308 "2021-09-24T12:54:10Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryanjmclaughlin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryanjmclaughlin/32/4318_2.png) [@ryanjmclaughlin](https://forum.inductiveautomation.com/u/ryanjmclaughlin)\
**Post date:** [September 24, 2021, 12:54pm UTC](https://forum.inductiveautomation.com/t/script-console-print-not-working/51308/1 "2021-09-24T12:54:11Z")

</div>

One of my other devs brought me a odd issue. After upgrading to 8.1.10 print statements when using script console for debugging stopped working. This only happens in specific situations where a custom class is used in the script, it almost seems as though the print() is being overridden somehow. However this issue did not occur in 8.1.6, so I assume this is related to the update to jython 2.7.2

I cannot find any obvious issues, any jython experts know of changes in 2.7.2 that could cause this?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [September 24, 2021, 2:19pm UTC](https://forum.inductiveautomation.com/t/script-console-print-not-working/51308/2 "2021-09-24T14:19:53Z")

</div>

Print _statements_ or print calls as a function? The latter would require `from __future__ import print_function` as the first line in whatever execution environment you’re in, on _any_ Python 2.X version.

---

<div class="post-metadata">

**Author:** ![ryanjmclaughlin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryanjmclaughlin/32/4318_2.png) [@ryanjmclaughlin](https://forum.inductiveautomation.com/u/ryanjmclaughlin)\
**Post date:** [September 24, 2021, 3:14pm UTC](https://forum.inductiveautomation.com/t/script-console-print-not-working/51308/3 "2021-09-24T15:14:59Z")

</div>

Sorry my bad lingo, print _statements_

Here is an example… where you see the print statement stops working after executing a function.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/1/615d94c78d0e4746ce13647aebba849863818a09.png)

I’d send you the code, but way to many dependencies on our specific environment in this code, so just trying to find some help looking for a direction to investigate.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [September 24, 2021, 3:40pm UTC](https://forum.inductiveautomation.com/t/script-console-print-not-working/51308/4 "2021-09-24T15:40:37Z")

</div>

Could the code be calling `System.exit()` or otherwise exiting ‘too fast’? I don’t think you can non-trivially break the `print` statement (outside of the aforementioned magic import to turn it into a function).

If you can annotate the code you’re calling with more `print`s, that may help identify where in the code it’s “stopping”.

---

<div class="post-metadata">

**Author:** ![nicoli.liedtke](https://avatars.discourse-cdn.com/v4/letter/n/ee59a6/32.png) [@nicoli.liedtke](https://forum.inductiveautomation.com/u/nicoli.liedtke)\
**Post date:** [September 30, 2021, 8:13pm UTC](https://forum.inductiveautomation.com/t/script-console-print-not-working/51308/5 "2021-09-30T20:13:45Z")

</div>

I can replicate this issue. In the attached screenshot I ran the script console twice. The first time nothing got printed after the class method was run and the second time all the prints came through fine. Every time I open a new designer this issue happens on the first execution. I am on version 8.1.10

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/7/b7a136aa6d225b35ee29146ddda805d459482d4e.png)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [September 30, 2021, 8:16pm UTC](https://forum.inductiveautomation.com/t/script-console-print-not-working/51308/6 "2021-09-30T20:16:41Z")

</div>

Can either of you provide an [SSCCE](http://sscce.org/) that demonstrates the problem?

---

<div class="post-metadata">

**Author:** ![cesrom](https://avatars.discourse-cdn.com/v4/letter/c/ea666f/32.png) [@cesrom](https://forum.inductiveautomation.com/u/cesrom)\
**Post date:** [October 28, 2021, 12:14am UTC](https://forum.inductiveautomation.com/t/script-console-print-not-working/51308/7 "2021-10-28T00:14:51Z")

</div>

I am running into a similar issue on 8.1.11, but on the Output Console.

This is the code on `actionPerformed` on a button:

```python
from __future__ import print_function

print("Hello world!")

```

But when I comment the `import`, I get the output for all previous clicks plus the last one, at once.

---

<div class="post-metadata">

**Author:** ![cesrom](https://avatars.discourse-cdn.com/v4/letter/c/ea666f/32.png) [@cesrom](https://forum.inductiveautomation.com/u/cesrom)\
**Post date:** [October 28, 2021, 8:18pm UTC](https://forum.inductiveautomation.com/t/script-console-print-not-working/51308/8 "2021-10-28T20:18:09Z")

</div>

Summoning @paul-griffith.

Could this be flagged as a bug and fixed on 8.1.12?

CC: @cmallonee

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [November 1, 2021, 3:36pm UTC](https://forum.inductiveautomation.com/t/script-console-print-not-working/51308/9 "2021-11-01T15:36:54Z")

</div>

I’ve been out for a week, but let’s get into it 🙂  
There’s pretty much no chance this is going to be fixed in 8.1.12; it’s too late in the game.

You posted a minimal example a few days ago, but that seems like a different issue than the main topic of this thread. It’s potentially a bug worth fixing (I’ll take a look at it) but without an SSCCE for the main issue I don’t have a lot to go forward with.

---

<div class="post-metadata">

**Author:** ![ryanjmclaughlin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryanjmclaughlin/32/4318_2.png) [@ryanjmclaughlin](https://forum.inductiveautomation.com/u/ryanjmclaughlin)\
**Post date:** [November 1, 2021, 4:16pm UTC](https://forum.inductiveautomation.com/t/script-console-print-not-working/51308/10 "2021-11-01T16:16:29Z")

</div>

I’m still trying to put together a SSCCE for you on the primary issue, just haven’t been able to carve a few hours out to do it… ☹

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [November 1, 2021, 6:56pm UTC](https://forum.inductiveautomation.com/t/script-console-print-not-working/51308/11 "2021-11-01T18:56:06Z")

</div>

> [@cesrom](#):
>
> But when I comment the `import` , I get the output for all previous clicks plus the last one, at once.

This doesn't work 'right' because the future import `print_function` isn't flushing the output stream for whatever reason.

---

<div class="post-metadata">

**Author:** ![kyler.kamyszek](https://avatars.discourse-cdn.com/v4/letter/k/a4c791/32.png) [@kyler.kamyszek](https://forum.inductiveautomation.com/u/kyler.kamyszek)\
**Post date:** [November 3, 2021, 6:03pm UTC](https://forum.inductiveautomation.com/t/script-console-print-not-working/51308/12 "2021-11-03T18:03:15Z")

</div>

I’ve also discovered this issue but I didn’t find a correlation between custom classes and the issue. 8.1.10

We used some logger functions though out the function we’re calling and the logs do post, but not the print statements or the return of the function.

It seems like the console output is just being dropped or truncated some how.

A second execute in the script console shows the expected output on the interpreter.

---

<div class="post-metadata">

**Author:** ![e.cutino](https://avatars.discourse-cdn.com/v4/letter/e/e5b9ba/32.png) [@e.cutino](https://forum.inductiveautomation.com/u/e.cutino)\
**Post date:** [March 12, 2023, 3:45pm UTC](https://forum.inductiveautomation.com/t/script-console-print-not-working/51308/13 "2023-03-12T15:45:45Z")

</div>

Hi PGriffith, I'm running in the same problem: the print() function (with use of \_ \_ future \_ \_ module) appears as no flushing the output stream (wrapper.log, print () used inside a timer script). If I remove the module \_ \_ future \_ \_ import and using print without (), it works. Quite strangely, if a second script is flushing on the wrapper, all is ok also with print(). The same script, in the Designer script console, properly works always. I wish to maintain the \_ \_ future \_ \_ module. Is there anything I can do? Many thanks.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 13, 2023, 3:58pm UTC](https://forum.inductiveautomation.com/t/script-console-print-not-working/51308/14 "2023-03-13T15:58:36Z")

</div>

The error was with Jython, but looks to be fixed in the latest patch release, so when we next update Jython in Ignition it'll be fixed:

> <https://github.com/jython/jython/pull/81>
>
> In CPython, \`from \_\_future\_\_ import print\_function\` works both in scripts and in…teractive interpreters; in the latter it can be enabled at any time and will apply to the parsing of all subsequent inputs. The same is true of \`unicode\_literals\`.
> 
> Jython implements this correctly in scripts, but it has never worked in interactive interpreters. This was reported early in Jython 2.7 development (https://bugs.jython.org/issue2007), but apparently today is the first time it's been sufficiently annoying for someone to dig into Jython guts and fix it ;)
> 
> The cause is that each input is handled by a new PythonParser, and PythonParser currently only enables future features if it sees the import statement itself. Fortunately the feature flags are also recorded in PythonInterpreter.cflags, and this is already passed to the ParserFacade that creates the parser instances, so it is straightforward to add the missing step and initialize the parser correctly.

---

<div class="post-metadata">

**Author:** ![e.cutino](https://avatars.discourse-cdn.com/v4/letter/e/e5b9ba/32.png) [@e.cutino](https://forum.inductiveautomation.com/u/e.cutino)\
**Post date:** [March 13, 2023, 4:52pm UTC](https://forum.inductiveautomation.com/t/script-console-print-not-working/51308/15 "2023-03-13T16:52:40Z")

</div>

Hi, many thanks for the information. It would be great to have a stand-alone "patch" for existing version, not feasible to update production environment for that.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 13, 2023, 5:21pm UTC](https://forum.inductiveautomation.com/t/script-console-print-not-working/51308/16 "2023-03-13T17:21:00Z")

</div>

That's not really how things work. Jython is tightly integrated throughout Ignition, so when we bump the version we have to regression test _all of Ignition_, which we also do with every product version.

If you, personally, want to take the _significantly_ more risky step of dropping in a new version of Jython to fix this minor issue, you can do so - just download the Jython release jar from Github into the gateway, in the `lib/core/common` folder, overwriting the existing Jython JAR. But be aware it's totally unsupported.
