Using Fiji to process python code in Fiji(Imagej)

What I am trying to do is using Fiji to run the sample code from the msim project.
In order to do it,I will need this programs to work with ImageJ.

  • Python 2.7.3
  • numpy 1.6.1
  • scipy 0.10.1
  • matplotlib 1.1.0
  • ipython 0.12

The first time I try to do it, I said the module numpy can not be imported, but I come up with an idea that download Jyni to my library to get the import issues fixed. However, another errors said

java.util.concurrent.ExecutionException: java.lang.UnsupportedClassVersionError: JyNI/JyNIInitializer : Unsupported major.minor version 51.0

I have done this all in Python environment but not in Jython, When I try to run the code in ImageJ, I also try to download Jyni to work with Jython, but I can not get it to work.
I got this error when I run it in ImageJ, using Jython

[ERROR] Module threw error java.lang.UnsupportedClassVersionError: JyNI/JyNIInitializer : Unsupported major.minor version 51.0

Could somebody tell me how to get the code to work or do I wasting my time to fix these problems…

Thank you very much.

1 Like

Unfortunately, Jython cannot import Python modules backed by native code, such as numpy and scipy.

However, various projects have laid some groundwork to make it possible to interact with such Python modules from ImageJ in the future. A motivated developer (maybe you? :wink:) could make it possible, with effort!

Please see this thread for details.

1 Like

Thank you very much for the reply!
I am a new developer, and I don’t know where to begin about this and the projects that you mentioned.
Would you give me some suggestion?

Thanks a lot.


In general, the path I am suggesting probably requires a more senior developer to tackle, since it requires significant knowledge of both Java and Python internals. Out of the box, you cannot use numpy and scipy with Jython.

That said, it might be possible to get JyNI working—I don’t know since I haven’t tried. The specific obstacle you are encountering can be overcome at least, by using a newer version of Java. See the section on UnsupportedClassVersionError on the Troubleshooting page.

If you get numpy and/or scipy working inside ImageJ using this path, we very much would love to hear about it! :grin:

1 Like