After fiji update, scripts don't work right

Hi.
I’m learning Fiji scripting by Python(Jython).
A week ago, I updated my fiji app and after that the scripts I wrote don’t work right.

Here is the error message I got.

java.lang.IllegalArgumentException: Cannot create PyString with non-byte value
at org.python.core.PyString.(PyString.java:57)
at org.python.core.PyString.(PyString.java:70)
at org.python.core.PyString.(PyString.java:74)
at org.python.core.Py.newString(Py.java:647)
at org.python.jsr223.PyScriptEngine.compileScript(PyScriptEngine.java:89)
at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:31)
at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
at org.scijava.script.ScriptModule.run(ScriptModule.java:160)
at org.scijava.module.ModuleRunner.run(ModuleRunner.java:168)
at org.scijava.module.ModuleRunner.call(ModuleRunner.java:127)
at org.scijava.module.ModuleRunner.call(ModuleRunner.java:66)
at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:228)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

I googled and found that if I use full width characters such as Chinese and Japanese the error shows up.
But in my case, I didn’t use those characters and the scripts work just right if I open a new script and copy paste the original code and run it.
This is the case with all the scripts I wrote so it’s not the problem of each code.

Environment
Mac OSX 10.14.6
Fiji imagej ver1.52p

Could anyone solve this problem?

1 Like

Hi @shime,

Welcome to the forum.

We’ll be able to help you more effectively if you post an example script that produces this error.
(Ideally the smallest script that causes the error)

John

1 Like

Hi bogovicj,

Here is the script.

from ij import IJ

imp = IJ.getImage()
ip = imp.getProcessor()

print imp
print ip

What is the title (name) of the image?

The title is “sample.png”.

Hey @shime

would you mind testing if this also happens with a freshly downloaded Fiji?

Cheers,
Robert

1 Like

Hi @haesleinhuepf
I installed freshly downloaded Fiji but still the error occurs.
After starting new Fiji for the first time, a popup showed up and recommended me to
update Fiji, so I tried both skipping the update and executing the update.
However, the error occurs in both cases.
What is weird is it works just right if I open a new script and copy paste the
whole code to the new script.

Would you mind sharing a functional and a non-functional script? Packed as a zip file? I suspect some charset issue…

1 Like

Please include an image as well

Hi @haesleinhuepf
I installed the older version of Fiji (2017 May 30) and it worked fine!
For the functional and a non-functional script, I’m not sure what they exactly are.
Could you give me more information? I’m new to programming and English is
my second language.

Hi @bogovicj

Here is the image I used.

You said a script doesn’t work anymore (not functional) but after copy-paste it does work (functional). We might need these two files. Ideally as a compressed ZIP archive file.

@haesleinhuepf
I found that even though the newly opened script works, it stops working once it is saved. This is the case with the latest version of Fiji. If I use the older version, it works.

1 Like

@haesleinhuepf
In case you might need the scripts.script.zip (1.4 KB)

1 Like

Hello shime -

Just one data point:

I do not get an error running your script on
ImageJ 2.0.0-rc-69/1.52r55, running on ubuntu 16.04 LTS.

I downloaded your “sample.png” image and your “script.zip.”
I opened the image and opened “print_width.py” in the script
editor, and ran it without issue. (I also tried saving the script
and reopening it. The reopened script also ran without issue.)

Thanks, mm

1 Like

Hi @mountain_man

Thank you for testing. I might have found the problem.

@haesleinhuepf
@bogovicj

I found that if the path of the script contains full-width character, the error occurs.
It seems the latest version of Fiji can’t handle full-width character in script’s path while the older version can do that. The path of the image doesn’t matter. The latest version can handle images the path of which contain full-width characters.
But, it can be true only on my computer so I would be glad if you could examine it.
There is also a chance that the problem occurs only for Japanese.
I’m not familiar with those charset or encoding things.

2 Likes