Python Script Interpreter fails

Tags: #<Tag:0x00007fb8828bd980> #<Tag:0x00007fb8828bd250>


I want to start rewriting the wiki page about Jython Scripting. Testing the first sections fails. The Script Interpreter is not able to run Python code. The interpreter for JavaScript works fine.

  1. Open Plugins > Scripting > Script Interpreter
  2. Select the Python tab.
  3. Enter some python code and hit Enter
  • I tried different code like print('Hello World!'), a = 1 and from ij import IJ

In Fiji the Script Interpreter looks different, but the problem is the same. Instead of printing the full error message, only the first line is shown.

>>> from ij import IJ
javax.script.ScriptException: SyntaxError: ("no viable alternative at input 'from'", ('<string>', 1, 0, 'from ij import IJ\n'))

    at org.scijava.plugins.scripting.jython.JythonScriptEngine.eval(
    at org.scijava.script.DefaultScriptInterpreter.eval(
    at net.imagej.ui.swing.script.interpreter.PromptPane.execute(
    at net.imagej.ui.swing.script.interpreter.PromptPane.access$000(
    at net.imagej.ui.swing.script.interpreter.PromptPane$1.keyPressed(
    at java.awt.Component.processKeyEvent(
    at javax.swing.JComponent.processKeyEvent(
    at java.awt.Component.processEvent(
    at java.awt.Container.processEvent(
    at java.awt.Component.dispatchEventImpl(
    at java.awt.Container.dispatchEventImpl(
    at java.awt.Component.dispatchEvent(
    at java.awt.KeyboardFocusManager.redispatchEvent(
    at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(
    at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(
    at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(
    at java.awt.DefaultKeyboardFocusManager.dispatchEvent(
    at java.awt.Component.dispatchEventImpl(
    at java.awt.Container.dispatchEventImpl(
    at java.awt.Window.dispatchEventImpl(
    at java.awt.Component.dispatchEvent(
    at java.awt.EventQueue.dispatchEventImpl(
    at java.awt.EventQueue.access$500(
    at java.awt.EventQueue$
    at java.awt.EventQueue$
    at Method)
    at java.awt.EventQueue$
    at java.awt.EventQueue$
    at Method)
    at java.awt.EventQueue.dispatchEvent(
    at java.awt.EventDispatchThread.pumpOneEventForFilters(
    at java.awt.EventDispatchThread.pumpEventsForFilter(
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(
    at java.awt.EventDispatchThread.pumpEvents(
    at java.awt.EventDispatchThread.pumpEvents(
Caused by: SyntaxError: ("no viable alternative at input 'from'", ('<string>', 1, 0, 'from ij import IJ\n'))

    at org.python.core.ParserFacade.fixParseError(
    at org.python.core.ParserFacade.parse(
    at org.python.core.CompileFunction.compile(
    at org.python.core.CompileFunction.compile(
    at org.python.core.CompileFunction.compile(
    at org.python.core.__builtin__.eval(
    at org.python.core.__builtin__.eval(
    at org.python.util.PythonInterpreter.eval(
    at org.scijava.plugins.scripting.jython.JythonScriptEngine.eval(
    ... 38 more


The unified Script Interpreter is currently in “beta status” as far as functionality; some languages including Jython unfortunately do not work. However, for that reason, I have not yet removed the individual language interpreters from Fiji. You can run Plugins > Scripting > Jython Interpreter and the instructions on the Jython Scripting page should work as described.

I edited the wiki page, adding a warning about the unified Script Interpreter plugin being beta quality.

I wish I had time to fix Jython in the new script interpreter, but I have too many other pressing priorities right now. If you want to take a crack at it, that would be most welcome.

Regardless, edits to the Jython Scripting page to improve it (especially to streamline it—it is rather a monster) would be fabulous.


Thx for the hint about the Jython Interpreter in Fiji.

This week I want to start rewriting the Jython Scripting page. First step is to present my concept in a forum post.


EDIT: So I realized that my Fiji was in fact not up to date… I ran the updater again this morning and everything is back to normal.

Why the updates were not applied the other day, I have no idea, nor do I understand why it stopped working sans any update… But it works now, so all is well.

I will piggyback on this thread because I ran into the same problem as you included in the first post @m-entrup (see SS below).

I have been using the script editor (jython) for over a year and this problem has never occured untill now, following a Fiji update. Suddenly none of my scripts will run, all resulting in the same error as in the included pic. I couldn’t say for sure which update caused the problem, as I had not run the updater for ~2 months untill yesterday evening, but see the bottom screencap for my current version info. If you need more info let me know and I will reply promptly.

Does anyone have a clue what went wrong? Can I fix it? I did some googling, and I found this discussion on GitHub, but I am more biologist than programmer. If someone could offer some advice, I would appreciate it.

The error could be on my end as well, I have not made any changes other than updating Fiji, but this is a networked university desktop, subject to updates from IT.

PS. pasting code to the jython interpreter still works.

(Windows 7 Enterprise)


@Sverre So based on your edit, do I understand correctly that all is well in your installation now? I did a quick test and could not reproduce the problem you describe in my fully updated Fiji using Jython.


Hi Curtis,

Yes, all is well after I ran the updater again. I have no idea what happened, but I guess it does not matter.