Using fiji API in Jupyter Notebook

Hello,

So I would like to use the Fiji API in jupyter Notebook. However I get this error when trying to use the imagej.init() method.

import os
path = os.getcwd()
import imagej
ij = imagej.init(path + ‘\Fiji.app’)

Unable to import scyjava dependency jnius.

Thank you

Your notebook may be running on the wrong python environment. Did you install pyimagej on a virtual environment? If so, you need to activate that environment in conda before starting Jupyter Notebooks.

1 Like

Yes, I activated the pyij environment using
“conda activate pyij” and I still can not import the "ij’ or “imagej” module. I would like to use it in jupyter notebook because xlsxwriter can not be used in the script services in fiji.

Thanks.

It might be worthile to try reinstalling pyimagej or to try directly installing pyjnius then, if the import has a problem with jnius.

If that doesn’t work, do you have the stack trace/full error? Where in imagej.py is it breaking when trying to import jnius?

So I reinstalled pyimagej and activated the environment. Instead of base it says (imagej). when i run python -c ‘import imagej; imagej.init()’ the error is missing 1 required positional argument. However, I have version 4.0 so it shouldn’t throw this error.

The error message after running
imagej.init("directory") is
Added 380 JARs to the Java classpath.
INFO 2019-03-25 16:43:02,261: Failed to bootstrap the artifact.
INFO 2019-03-25 16:43:02,261:
INFO 2019-03-25 16:43:02,262: Possible solutions:
INFO 2019-03-25 16:43:02,262: * Double check the endpoint for correctness (https://search.maven.org/).
INFO 2019-03-25 16:43:02,263: * Add needed repositories to ~/.jgorc [repositories] block (see README).
INFO 2019-03-25 16:43:02,263: * Try with an explicit version number (release metadata might be wrong).

Did you run this verbatim? Or did you point to an actual directory on your system containing an ImageJ installation? If so, what was the path you used?

imagej.init(‘C:\Users\NT3130\Desktop\Fiji.app’) I ran this.

I used the path where the fiji launcher is.