Java exception when initialising pyimagej

Hello,

I’m trying to initialise pyimagej with a python kernel and the FIJI plugins. Both instructions: imagej.init(’/Applications/Fiji.app’) and ij = imagej.init(‘sc.fiji:fiji’) return me the following java exception. The simpler imagej.init() instruction works but that is not enough for me.

Traceback (most recent call last):

File “ImageJ.java”, line 77, in net.imagej.ImageJ.
File “Context.java”, line 160, in org.scijava.Context.
File “Context.java”, line 174, in org.scijava.Context.
File “Context.java”, line 234, in org.scijava.Context.
File “Context.java”, line 278, in org.scijava.Context.
File “ServiceHelper.java”, line 164, in org.scijava.service.ServiceHelper.loadServices
File “ServiceHelper.java”, line 192, in org.scijava.service.ServiceHelper.loadService
File “ServiceHelper.java”, line 229, in org.scijava.service.ServiceHelper.loadService
File “ServiceHelper.java”, line 267, in org.scijava.service.ServiceHelper.createExactService
File “ServiceHelper.java”, line 315, in org.scijava.service.ServiceHelper.createServiceRecursively
File “ClassUtils.java”, line 163, in org.scijava.util.ClassUtils.getAnnotatedFields
File “ClassUtils.java”, line 193, in org.scijava.util.ClassUtils.getAnnotatedFields
File “ArrayList.java”, line 583, in java.util.ArrayList.addAll

java.lang.NullPointerException: java.lang.NullPointerException

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

File “ImageJ.java”, line 77, in net.imagej.ImageJ.
File “Context.java”, line 160, in org.scijava.Context.
File “Context.java”, line 174, in org.scijava.Context.
File “Context.java”, line 234, in org.scijava.Context.
File “Context.java”, line 278, in org.scijava.Context.
File “ServiceHelper.java”, line 164, in org.scijava.service.ServiceHelper.loadServices
File “ServiceHelper.java”, line 192, in org.scijava.service.ServiceHelper.loadService
File “ServiceHelper.java”, line 229, in org.scijava.service.ServiceHelper.loadService
File “ServiceHelper.java”, line 278, in org.scijava.service.ServiceHelper.createExactService
Exception: Java Exception

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

File “”, line 1, in
ij = imagej.init(’/Applications/Fiji.app’)

File “/Users/andrea/opt/anaconda3/envs/pyimagej/lib/python3.8/site-packages/imagej/init.py”, line 168, in init
ij = ImageJ()

java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: Invalid service: sc.fiji.filamentdetector.gui.GUIStatusService

I’ve installed the pyimagej 1.0.0 using conda and openjdk=8 and I’m running the code with Spyder. I’m sure Spyder has been launched from the same conda environment where pyimagej is installed. I’m running macOS version 10.15.7.

Thank you for your wisdom.

Andrea

1 Like

I also tried this: ij = imagej.init(’/Applications/Fiji.app/Contents/MacOS/ImageJ-macosx’)

ij = imagej.init(’/Applications/Fiji.app/Contents/MacOS/’)
Traceback (most recent call last):
File “”, line 1, in
File “/Users/andrea/opt/anaconda3/envs/pyimagej/lib/python3.8/site-packages/imagej/init.py”, line 167, in init
ImageJ = sj.jimport(‘net.imagej.ImageJ’)
File “/Users/andrea/opt/anaconda3/envs/pyimagej/lib/python3.8/site-packages/scyjava/init.py”, line 151, in jimport
return jpype.JClass(class_name)
File “/Users/andrea/opt/anaconda3/envs/pyimagej/lib/python3.8/site-packages/jpype/_jclass.py”, line 99, in new
return _jpype._getClass(jc)
TypeError: Class net.imagej.ImageJ is not found