Python Script Interpreter fails

script-interpreter
python
Tags: #<Tag:0x00007fb8828bd980> #<Tag:0x00007fb8828bd250>

#1

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(JythonScriptEngine.java:67)
    at org.scijava.script.DefaultScriptInterpreter.eval(DefaultScriptInterpreter.java:89)
    at net.imagej.ui.swing.script.interpreter.PromptPane.execute(PromptPane.java:128)
    at net.imagej.ui.swing.script.interpreter.PromptPane.access$000(PromptPane.java:54)
    at net.imagej.ui.swing.script.interpreter.PromptPane$1.keyPressed(PromptPane.java:77)
    at java.awt.Component.processKeyEvent(Component.java:6493)
    at javax.swing.JComponent.processKeyEvent(JComponent.java:2832)
    at java.awt.Component.processEvent(Component.java:6312)
    at java.awt.Container.processEvent(Container.java:2236)
    at java.awt.Component.dispatchEventImpl(Component.java:4891)
    at java.awt.Container.dispatchEventImpl(Container.java:2294)
    at java.awt.Component.dispatchEvent(Component.java:4713)
    at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1954)
    at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:806)
    at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1074)
    at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:945)
    at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:771)
    at java.awt.Component.dispatchEventImpl(Component.java:4762)
    at java.awt.Container.dispatchEventImpl(Container.java:2294)
    at java.awt.Window.dispatchEventImpl(Window.java:2750)
    at java.awt.Component.dispatchEvent(Component.java:4713)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
    at java.awt.EventQueue$4.run(EventQueue.java:731)
    at java.awt.EventQueue$4.run(EventQueue.java:729)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: SyntaxError: ("no viable alternative at input 'from'", ('<string>', 1, 0, 'from ij import IJ\n'))

    at org.python.core.ParserFacade.fixParseError(ParserFacade.java:92)
    at org.python.core.ParserFacade.parse(ParserFacade.java:199)
    at org.python.core.CompileFunction.compile(__builtin__.java:1512)
    at org.python.core.CompileFunction.compile(__builtin__.java:1488)
    at org.python.core.CompileFunction.compile(__builtin__.java:1480)
    at org.python.core.__builtin__.eval(__builtin__.java:479)
    at org.python.core.__builtin__.eval(__builtin__.java:488)
    at org.python.util.PythonInterpreter.eval(PythonInterpreter.java:190)
    at org.scijava.plugins.scripting.jython.JythonScriptEngine.eval(JythonScriptEngine.java:64)
    ... 38 more



#2

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.


#3

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.


#4

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)


#5

@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.


#6

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.

Cheers,

Sverre