pyimageJ image.init troubles


I have been trying to setup pyimageJ using anaconda version: 4.7.12 but I have been struggling to get it working. I have tried the following:

conda create -n imagej -c conda-forge openjdk=8 pyimagej

conda activate imagej

This environment (imagej) does not have Jupyter installed and so I have tried installing this either by using:

conda install -c anaconda jupyter

Or using the anaconda navigator.

After doing this, I launch Jupyter notebook and create a new python 3 notebook. I then try:

import imagej
ij = imagej.init('sc.fiji:fiji:2.0.0-pre-10')

Or attempt to direct the init function to my local copy of Fiji. Each time, I get the following error:

Error in `~/opt/anaconda3/envs/imagej/bin/mvn -B -f ~/.jgo/sc.fiji/fiji/2.0.0-pre-10+net.imglib2-imglib2-imglyb-0.4.0/pom.xml dependency:resolve': 1
ERROR:root:Internal Python error in the inspect module.

Below is the traceback from this internal error.

And then a traceback error.

Has anyone had a similar problem? Any help would be greatly appreciated.




I have a similar error with launching pyimagej.

This is the error I got with python -c "import imagej; ij = imagej.init('sc.fiji:fiji:2.1.1'); print(ij.getVersion()); ij.dispose()"

Error in `C:\Users\sabri\miniconda3\envs\pyimagej\Library\bin\mvn.CMD -B -f C:\Users\sabri\.jgo\net.imglib2\imglib2-imglyb\1.0.0+net.imagej-imagej-legacy-RELEASE+sc.fiji-fiji-2.1.1\pom.xml dependency:resolve': 1

And here’s a different error when I launched the local version of ImageJ using python -c "import imagej; ij = imagej.init(r'C:\'); print(ij.getVersion()); ij.dispose()"

Error in `C:\Users\sabri\miniconda3\envs\pyimagej\Library\bin\mvn.CMD -B -f C:\Users\sabri\.jgo\net.imglib2\imglib2-imglyb\1.0.0\pom.xml dependency:resolve': 1

I tried to run the verbose tag (with -X), but problem was not solved. I would really appreciate if anyone could share the solution, if the problem was solved.


1 Like

Hi @wusabbrin! Thank you for the details - I’m sorry you’ve been having trouble with PyImageJ.

So I think the reason it fails even with a local Fiji is that PyImageJ requires a bit of extra java code (imglib2-imglyb) which is not included in standard Fiji distributions. This java code is still retrieved with Maven and then runs into the same Maven problem you’re seeing with the first initialization.

As for why Maven failed…

The dependency:resolve function doesn’t actually download anything, I believe, or at least not to the location required by PyImageJ. Let’s try downloading everything manually, using copy-dependencies instead of resolve, which will also tell us if your Maven is working OK.

To download for the local installation:

C:\Users\sabri\miniconda3\envs\pyimagej\Library\bin\mvn.CMD -B -f C:\Users\sabri\.jgo\net.imglib2\imglib2-imglyb\1.0.0\pom.xml dependency:copy-dependencies -DoutputDirectory=C:\Users\sabri\.jgo\net.imglib2\imglib2-imglyb\1.0.0\

For fiji-2.1.1 you would just update the two file paths, changing

If the download is successful you should see a bunch of .jar files in the .jgo\net.imglib2\imglib2-imglyb\1.0.0 directory. If not, could you run the copy-dependencies command again with -X and post the results here?

If the copy-dependencies works, then you should be able to try imagej.init() again.