Python scripts fail in ImageJ

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Python scripts fail in ImageJ

Jirka
This post was updated on .
Hello,
may I have question about running a python scripts in ImageJ. I know that I
was using it about a year ago and it worked, but now somehow it does not
work at all. Just to be sure I download actual clear Fiji version
(Life-Line version, 2014 November 25 for Linux 64bit) and created simple
script that contains just a few lines:

--------------------------------------------------------
# test run
import time, sys
from ij import IJ

IJ.exit()
--------------------------------------------------------

Then I call it using parameter "batch" so
~/Applications/Fiji.app/ImageJ-linux64 -batch
"/home.dokt/borovji3/Desktop/tmp_run.py"

but then I got just this error message:

log4j:WARN No appenders could be found for logger
(org.bushe.swing.event.EventService).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for
more info.
java.lang.IllegalArgumentException: Cannot modify method: public void run()
at net.imagej.patcher.CodeHacker.insertAtTopOfMethod(CodeHacker.java:167)
at
net.imagej.patcher.LegacyExtensions.injectHooks(LegacyExtensions.java:229)
at net.imagej.patcher.LegacyInjector.inject(LegacyInjector.java:308)
at net.imagej.patcher.LegacyInjector.injectHooks(LegacyInjector.java:109)
at
net.imagej.patcher.LegacyEnvironment.initialize(LegacyEnvironment.java:101)
at
net.imagej.patcher.LegacyEnvironment.applyPatches(LegacyEnvironment.java:495)
at net.imagej.patcher.LegacyInjector.preinit(LegacyInjector.java:397)
at net.imagej.patcher.LegacyInjector.preinit(LegacyInjector.java:376)
at
net.imagej.legacy.DefaultLegacyService.<clinit>(DefaultLegacyService.java:124)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at
org.scijava.service.ServiceHelper.createServiceRecursively(ServiceHelper.java:302)
at
org.scijava.service.ServiceHelper.createExactService(ServiceHelper.java:269)
at org.scijava.service.ServiceHelper.loadService(ServiceHelper.java:231)
at org.scijava.service.ServiceHelper.loadService(ServiceHelper.java:194)
at org.scijava.service.ServiceHelper.loadServices(ServiceHelper.java:166)
at org.scijava.Context.<init>(Context.java:244)
at org.scijava.Context.<init>(Context.java:203)
at org.scijava.Context.<init>(Context.java:142)
at org.scijava.Context.<init>(Context.java:98)
at org.scijava.Context.<init>(Context.java:86)
at net.imagej.ImageJ.<init>(ImageJ.java:82)
at net.imagej.Main.launch(Main.java:61)
at net.imagej.Main.main(Main.java:73)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at net.imagej.launcher.ClassLauncher.launch(ClassLauncher.java:258)
at net.imagej.launcher.ClassLauncher.run(ClassLauncher.java:184)
at net.imagej.launcher.ClassLauncher.main(ClassLauncher.java:76)
Caused by: java.lang.IllegalArgumentException: No such class:
JavaScriptEvaluator
at net.imagej.patcher.CodeHacker.getClass(CodeHacker.java:880)
at net.imagej.patcher.CodeHacker.getMethod(CodeHacker.java:906)
at net.imagej.patcher.CodeHacker.getBehavior(CodeHacker.java:896)
at net.imagej.patcher.CodeHacker.insertAtTopOfMethod(CodeHacker.java:158)
... 34 more
Caused by: javassist.NotFoundException: JavaScriptEvaluator
at javassist.ClassPool.get(ClassPool.java:450)
at net.imagej.patcher.CodeHacker.getClass(CodeHacker.java:875)
... 37 more
[WARNING] Opening was canceled.

Does anyone has an advice?

Thanks
--
Best regards, Jiri Borovec
----------------------------------------------------------------------------------------------------
Jiří Borovec <jiri.borovec@fel.cvut.cz>
PhD student at CMP CTU, ISC member
http://cmp.felk.cvut.cz/~borovji3

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: [fiji-devel] Python scripts fail in ImageJ

Mark Hiner
Hi Jiri,

>but then I got just this error message:

It looks like something was broken running Fiji from the command line in
general, and not explicitly related to scripting. I would recommend
developing your script in the script editor
<http://imagej.net/Using_the_Script_Editor> for now if you can.

I created a bug report <http://fiji.sc/bugzilla/show_bug.cgi?id=964> to
track the issue. We're at the end of a long overhaul of Fiji to bring all
of its components to a truly stable state, so I assume some version skew
crept into the live version, causing the specified class not to be found.

>IJ.exit()

Just a side note that there is no exit method in the IJ class
<https://github.com/imagej/ImageJA/blob/master/src/main/java/ij/IJ.java>.
But I can, for example, IJ.log in the script editor with no problem.

Apologies for the inconvenience. Thank you for reporting it though!

Best,
Mark

On Wed, Nov 26, 2014 at 6:55 AM, Jiří Borovec <[hidden email]>
wrote:

> Hello,
> may I have question about running a python scripts in ImageJ. I know that
> I was using it about a year ago and it worked, but now somehow it does not
> work at all. Just to be sure I download actual clear Fiji version
> (Life-Line version, 2014 November 25 for Linux 64bit) and created simple
> script that contains just a few lines:
>
> --------------------------------------------------------
> # test run
> import time, sys
> from ij import IJ
>
> IJ.exit()
> --------------------------------------------------------
>
> Then I call it using parameter "batch" so
> ~/Applications/Fiji.app/ImageJ-linux64 -batch
> "/home.dokt/borovji3/Desktop/tmp_run.py"
>
> but then I got just this error message:
>
> log4j:WARN No appenders could be found for logger
> (org.bushe.swing.event.EventService).
> log4j:WARN Please initialize the log4j system properly.
> log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for
> more info.
> java.lang.IllegalArgumentException: Cannot modify method: public void run()
> at net.imagej.patcher.CodeHacker.insertAtTopOfMethod(CodeHacker.java:167)
> at
> net.imagej.patcher.LegacyExtensions.injectHooks(LegacyExtensions.java:229)
> at net.imagej.patcher.LegacyInjector.inject(LegacyInjector.java:308)
> at net.imagej.patcher.LegacyInjector.injectHooks(LegacyInjector.java:109)
> at
> net.imagej.patcher.LegacyEnvironment.initialize(LegacyEnvironment.java:101)
> at
> net.imagej.patcher.LegacyEnvironment.applyPatches(LegacyEnvironment.java:495)
> at net.imagej.patcher.LegacyInjector.preinit(LegacyInjector.java:397)
> at net.imagej.patcher.LegacyInjector.preinit(LegacyInjector.java:376)
> at
> net.imagej.legacy.DefaultLegacyService.<clinit>(DefaultLegacyService.java:124)
> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
> at
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
> at
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
> at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
> at java.lang.Class.newInstance0(Class.java:355)
> at java.lang.Class.newInstance(Class.java:308)
> at
> org.scijava.service.ServiceHelper.createServiceRecursively(ServiceHelper.java:302)
> at
> org.scijava.service.ServiceHelper.createExactService(ServiceHelper.java:269)
> at org.scijava.service.ServiceHelper.loadService(ServiceHelper.java:231)
> at org.scijava.service.ServiceHelper.loadService(ServiceHelper.java:194)
> at org.scijava.service.ServiceHelper.loadServices(ServiceHelper.java:166)
> at org.scijava.Context.<init>(Context.java:244)
> at org.scijava.Context.<init>(Context.java:203)
> at org.scijava.Context.<init>(Context.java:142)
> at org.scijava.Context.<init>(Context.java:98)
> at org.scijava.Context.<init>(Context.java:86)
> at net.imagej.ImageJ.<init>(ImageJ.java:82)
> at net.imagej.Main.launch(Main.java:61)
> at net.imagej.Main.main(Main.java:73)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at net.imagej.launcher.ClassLauncher.launch(ClassLauncher.java:258)
> at net.imagej.launcher.ClassLauncher.run(ClassLauncher.java:184)
> at net.imagej.launcher.ClassLauncher.main(ClassLauncher.java:76)
> Caused by: java.lang.IllegalArgumentException: No such class:
> JavaScriptEvaluator
> at net.imagej.patcher.CodeHacker.getClass(CodeHacker.java:880)
> at net.imagej.patcher.CodeHacker.getMethod(CodeHacker.java:906)
> at net.imagej.patcher.CodeHacker.getBehavior(CodeHacker.java:896)
> at net.imagej.patcher.CodeHacker.insertAtTopOfMethod(CodeHacker.java:158)
> ... 34 more
> Caused by: javassist.NotFoundException: JavaScriptEvaluator
> at javassist.ClassPool.get(ClassPool.java:450)
> at net.imagej.patcher.CodeHacker.getClass(CodeHacker.java:875)
> ... 37 more
> [WARNING] Opening was canceled.
>
> Does anyone has an advice?
>
> Thanks
> --
> Best regards, Jiri Borovec
>
> ----------------------------------------------------------------------------------------------------
> Ing. Jiri Borovec, MSc                           <[hidden email]
> >
> PhD student at CMP CTU, member ISC  |       tel.: +420 2 2435 7590
> http://cmp.felk.cvut.cz/~borovji3             |    mob.: +420 728 480 285
>
> --
> --
> Please avoid top-posting, and please make sure to reply-to-all!
>
> Mailing list web interface: http://groups.google.com/group/fiji-devel
>
> ---
> You received this message because you are subscribed to the Google Groups
> "Fiji-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [hidden email].
> For more options, visit https://groups.google.com/d/optout.
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html