Script editor error when working with python scripts

Using a simple python script on a windows 7 machine

print "hello"

upon execution I find the following in the console

console: Failed to install '': java.nio.charset.UnsupportedCharsetException: cp0.

Another error that I encountered (weirdly not every time) when opening this macro

(Fiji Is Just) ImageJ 2.0.0-rc-61/1.51n; Java 1.8.0_66 [64-bit]; Windows 7 6.1; 310MB of 50000MB (<1%)
java.lang.Error: Error: could not match input
	at org.fife.ui.rsyntaxtextarea.modes.PythonTokenMaker.zzScanError(
	at org.fife.ui.rsyntaxtextarea.modes.PythonTokenMaker.yylex(
	at org.fife.ui.rsyntaxtextarea.modes.PythonTokenMaker.getTokenList(
	at org.fife.ui.rsyntaxtextarea.TokenMakerBase.getLastTokenTypeOnLine(
	at org.fife.ui.rsyntaxtextarea.RSyntaxDocument.updateSyntaxHighlightingInformation(
	at org.fife.ui.rsyntaxtextarea.RSyntaxDocument.setSyntaxStyle(
	at org.fife.ui.rsyntaxtextarea.RSyntaxTextArea.setSyntaxEditingStyle(
	at org.scijava.ui.swing.script.EditorPane.setLanguage(
	at org.scijava.ui.swing.script.EditorPane.setLanguage(
	at org.scijava.ui.swing.script.EditorPane.setLanguageByFileName(
	at org.scijava.ui.swing.script.EditorPane.setFileName(
	at org.scijava.ui.swing.script.TextEditor.setEditorPaneFileName(
	at net.imagej.legacy.DefaultLegacyHooks.openInEditor(
	at ij.plugin.DragAndDrop.openFile(

On Mac OSx there are no error messages, but when running the macro nothing happens.
any ideas?

(@ctrueden :wink: )

Seems to be related to this bug on windows (I had the same message a while ago in my app):

Try to pass the suggested JVM argument:



Possibly the issue is fixed in 2.7.1 (I don’t need the flag anymore - no I have classpath problems;-))

1 Like

hi @Bio7

I saw that, but given the age of the bug, I hoped that it wouldn’t be this. Also it wasn’t an issue before…

thanks for the workaround

Does the workaround -Dpython.console.encoding=UTF-8 work? If so, should we put that somewhere automatically?

Does it work with Jython 2.7.1? (You can test by cloning this project, changing the 2.7.0 to 2.7.1-rc3, building it, and using the resultant JAR in place of the old one in a Fiji installation.)

hi @Bio7 and @ctrueden

Yes, launching fiji with the above arguments prevent the error bellow from appearing in the console

console: Failed to install '': java.nio.charset.UnsupportedCharsetException: cp0.

I also tried this suggestion above. The behavior is the same; error wihtout additional launch arguments and no error with the arguments.

But there is another problem: The following works: ``` print "hello" ``` But when structuring the script as bellow, nothing happens, no "hello", no error... nothing. This is the case with or without the launch arguments and also with the newer jython version. ``` def hello(): print "hello"

if name == “main”:

this breaks most of my scripts.
1 Like

Dear @FelixM,
I think it could be related to this issue:

solved that way by @imagejan

if __name__ in ['__builtin__', '__main__']:

hoping to be helpful,

if __name__ in ['__builtin__', '__main__']:

yes, you are right @emartini, this does the tricks, with or without additional launch arguments and also for the 2.7.0 jython despite the mentioned console output bellow.


1 Like

I am sorry to break your scripts.

We cannot go back to Jython 2.5.3 because it has critical memory leaks which were fixed in 2.7.0 (and besides, lots of people want 2.7.0 for various new features etc.).

We cannot go to 2.7.1 due to critical new performance problems, and anyway as you pointed out, 2.7.1 does not fix these new problems.

If anyone has patches which mitigate the issues (e.g., as hinted above, adding System.setProperty("python.console.encoding", "UTF-8") somewhere early), please contribute. My time is unfortunately booked solid through October.