AttributeError: 'net.imagej.ImageJ' object has no attribute 'py'

Hi guys.

I installed imageJ package and I am running the following simple example in jupyter notebook.

import imagej
from skimage import io

fiji_path = "/home/amath/Downloads/fiji-linux64/Fiji.app"

ij = imagej.init(fiji_path)
img = io.imread('https://samples.fiji.sc/new-lenna.jpg')

inverted = ij.op().transform().invertAxisView(ij.py.to_java(img), 1)
result = ij.py.from_java(inverted)
ij.py.show(result)

However, I get the following error:

AttributeError: 'net.imagej.ImageJ' object has no attribute 'py'

The code is running using conda environment on python==3.7.6 with the following packages: imagej==0.3.1, imglyb==0.4.0, etc…

Do you have any idea why I am getting this error?

Here are also some additional information that may help:

  1. Below you can see all packages I installed in the environment I am using:
$ conda list
# packages in environment at /home/amath/anaconda3/envs/pyimagej:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                      1_llvm    conda-forge
attrs                     19.3.0                     py_0    conda-forge
backcall                  0.1.0                      py_0    conda-forge
bleach                    3.1.3              pyh8c360ce_0    conda-forge
bzip2                     1.0.8                h516909a_2    conda-forge
ca-certificates           2019.11.28           hecc5488_0    conda-forge
cairo                     1.16.0            hcf35c78_1003    conda-forge
certifi                   2019.11.28       py37hc8dfbb8_1    conda-forge
cffi                      1.14.0           py37hd463f26_0    conda-forge
chardet                   3.0.4                    pypi_0    pypi
cloudpickle               1.3.0                      py_0    conda-forge
colorcet                  2.0.1                      py_0    conda-forge
cryptography              2.8              py37hb09aad4_2    conda-forge
cycler                    0.10.0                     py_2    conda-forge
cython                    0.29.15                  pypi_0    pypi
cytoolz                   0.10.1           py37h516909a_0    conda-forge
dask-core                 2.12.0                     py_0    conda-forge
dbus                      1.13.6               he372182_0    conda-forge
decorator                 4.4.2                      py_0    conda-forge
defusedxml                0.6.0                      py_0    conda-forge
entrypoints               0.3             py37hc8dfbb8_1001    conda-forge
expat                     2.2.9                he1b5a44_2    conda-forge
ffmpeg                    4.1.3                h167e202_0    conda-forge
fontconfig                2.13.1            h86ecdb6_1001    conda-forge
freetype                  2.10.1               he06d7ca_0    conda-forge
gettext                   0.19.8.1          hc5be6a0_1002    conda-forge
giflib                    5.2.1                h516909a_2    conda-forge
glib                      2.58.3          py37he00f558_1003    conda-forge
gmp                       6.2.0                he1b5a44_2    conda-forge
gnutls                    3.6.5             hd3a4fd2_1002    conda-forge
graphite2                 1.3.13            he1b5a44_1001    conda-forge
gst-plugins-base          1.14.5               h0935bb2_2    conda-forge
gstreamer                 1.14.5               h36ae1b5_2    conda-forge
harfbuzz                  2.4.0                h9f30f68_3    conda-forge
hdf5                      1.10.5          nompi_h3c11f04_1104    conda-forge
icu                       64.2                 he1b5a44_1    conda-forge
idna                      2.9                      pypi_0    pypi
imageio                   2.8.0                      py_0    conda-forge
imagej                    0.3.1                    pypi_0    pypi
imglyb                    0.4.0            py37h5ca1d4c_0    conda-forge
importlib-metadata        1.5.0            py37hc8dfbb8_1    conda-forge
importlib_metadata        1.5.0                         1    conda-forge
ipydatawidgets            4.0.1                      py_0    conda-forge
ipykernel                 5.1.4            py37h5ca1d4c_0    conda-forge
ipympl                    0.5.6              pyh8c360ce_0    conda-forge
ipyscales                 0.4.0                      py_1    conda-forge
ipython                   7.13.0           py37h43977f1_1    conda-forge
ipython_genutils          0.2.0                      py_1    conda-forge
ipywidgets                7.5.1                      py_0    conda-forge
itk                       5.0.1                    py37_1    conda-forge
itk-core                  5.0.1                    pypi_0    pypi
itk-filtering             5.0.1                    pypi_0    pypi
itk-numerics              5.0.1                    pypi_0    pypi
itk-registration          5.0.1                    pypi_0    pypi
itk-segmentation          5.0.1                    pypi_0    pypi
itkwidgets                0.26.0                   py37_0    conda-forge
jasper                    1.900.1           h07fcdf6_1006    conda-forge
jedi                      0.16.0           py37hc8dfbb8_1    conda-forge
jgo                       0.5.0            py37hc8dfbb8_1    conda-forge
jinja2                    2.11.1                     py_0    conda-forge
jnius                     1.1.0                    pypi_0    pypi
jpeg                      9c                h14c3975_1001    conda-forge
jsonschema                3.2.0            py37hc8dfbb8_1    conda-forge
jupyter                   1.0.0                      py_2    conda-forge
jupyter_client            6.1.0                      py_0    conda-forge
jupyter_console           6.1.0                      py_1    conda-forge
jupyter_core              4.6.3            py37hc8dfbb8_1    conda-forge
kiwisolver                1.1.0            py37h99015e2_1    conda-forge
lame                      3.100             h14c3975_1001    conda-forge
ld_impl_linux-64          2.34                 h53a641e_0    conda-forge
libblas                   3.8.0               16_openblas    conda-forge
libcblas                  3.8.0               16_openblas    conda-forge
libclang                  9.0.1           default_hde54327_0    conda-forge
libffi                    3.2.1             he1b5a44_1007    conda-forge
libgcc-ng                 9.2.0                h24d8f2e_2    conda-forge
libgfortran-ng            7.3.0                hdf63c60_5    conda-forge
libiconv                  1.15              h516909a_1006    conda-forge
liblapack                 3.8.0               16_openblas    conda-forge
liblapacke                3.8.0               16_openblas    conda-forge
libllvm9                  9.0.1                hc9558a2_0    conda-forge
libopenblas               0.3.9                h5ec1e0e_0    conda-forge
libopencv                 4.2.0                    py37_2    conda-forge
libpng                    1.6.37               hed695b0_1    conda-forge
libsodium                 1.0.17               h516909a_0    conda-forge
libstdcxx-ng              9.2.0                hdf63c60_2    conda-forge
libtiff                   4.1.0                hc7e4089_6    conda-forge
libuuid                   2.32.1            h14c3975_1000    conda-forge
libwebp                   1.0.2                h56121f0_5    conda-forge
libwebp-base              1.1.0                         2    conda-forge
libxcb                    1.13              h14c3975_1002    conda-forge
libxkbcommon              0.10.0               he1b5a44_0    conda-forge
libxml2                   2.9.10               hee79883_0    conda-forge
llvm-openmp               9.0.1                hc9558a2_2    conda-forge
lz4-c                     1.8.3             he1b5a44_1001    conda-forge
markupsafe                1.1.1            py37h8f50634_1    conda-forge
matplotlib                3.2.1                         0    conda-forge
matplotlib-base           3.2.1            py37h30547a4_0    conda-forge
maven                     0.1.0                    pypi_0    pypi
mistune                   0.8.4           py37h516909a_1000    conda-forge
nbconvert                 5.6.1                    py37_0    conda-forge
nbformat                  5.0.4                      py_0    conda-forge
ncurses                   6.1               hf484d3e_1002    conda-forge
nettle                    3.4.1             h1bed415_1002    conda-forge
networkx                  2.4                        py_1    conda-forge
notebook                  6.0.3                    py37_0    conda-forge
nspr                      4.25                 he1b5a44_0    conda-forge
nss                       3.47                 he751ad9_0    conda-forge
numpy                     1.18.1           py37h95a1406_0    conda-forge
olefile                   0.46                       py_0    conda-forge
opencv                    4.2.0                    py37_2    conda-forge
openh264                  1.8.0             hdbcaa40_1000    conda-forge
openjdk                   8.0.192           h516909a_1004    conda-forge
openssl                   1.1.1e               h516909a_0    conda-forge
pandas                    1.0.0                    pypi_0    pypi
pandoc                    2.9.2                         0    conda-forge
pandocfilters             1.4.2                      py_1    conda-forge
param                     1.9.3                      py_0    conda-forge
parso                     0.6.2                      py_0    conda-forge
pcre                      8.44                 he1b5a44_0    conda-forge
pexpect                   4.8.0            py37hc8dfbb8_1    conda-forge
pickleshare               0.7.5           py37hc8dfbb8_1001    conda-forge
pillow                    7.0.0                    pypi_0    pypi
pip                       20.0.2                     py_2    conda-forge
pixman                    0.38.0            h516909a_1003    conda-forge
prometheus_client         0.7.1                      py_0    conda-forge
prompt-toolkit            3.0.4                      py_0    conda-forge
prompt_toolkit            3.0.4                         0    conda-forge
psutil                    5.7.0            py37h8f50634_1    conda-forge
pthread-stubs             0.4               h14c3975_1001    conda-forge
ptyprocess                0.6.0                   py_1001    conda-forge
py-opencv                 4.2.0            py37h5ca1d4c_2    conda-forge
pycparser                 2.20                       py_0    conda-forge
pyct                      0.4.6                      py_0    conda-forge
pyct-core                 0.4.6                      py_0    conda-forge
pygments                  2.6.1                      py_0    conda-forge
pyimagej                  0.5.0                    py37_0    conda-forge
pyjnius                   1.2.0                    pypi_0    pypi
pyopenssl                 19.1.0                     py_1    conda-forge
pyparsing                 2.4.6                      py_0    conda-forge
pyqt                      5.12.3           py37hcca6a23_1    conda-forge
pyqt5-sip                 4.19.18                  pypi_0    pypi
pyqtwebengine             5.12.1                   pypi_0    pypi
pyrsistent                0.15.7           py37h8f50634_1    conda-forge
pysocks                   1.7.1            py37hc8dfbb8_1    conda-forge
python                    3.7.6           h357f687_4_cpython    conda-forge
python-dateutil           2.8.1                      py_0    conda-forge
python_abi                3.7                     1_cp37m    conda-forge
pytz                      2019.3                   pypi_0    pypi
pywavelets                1.1.1            py37hc1659b7_0    conda-forge
pyyaml                    5.3.1            py37h8f50634_0    conda-forge
pyzmq                     19.0.0           py37hac76be4_1    conda-forge
qt                        5.12.5               hd8c4c69_1    conda-forge
qtconsole                 4.7.1                      py_0    conda-forge
qtpy                      1.9.0                      py_0    conda-forge
readline                  8.0                  hf8c457e_0    conda-forge
requests                  2.23.0                   pypi_0    pypi
scikit-image              0.16.2           py37hb3f55d8_0    conda-forge
scipy                     1.4.1            py37h921218d_0    conda-forge
scyjava                   0.4.0                    py37_0    conda-forge
send2trash                1.5.0                      py_0    conda-forge
setuptools                46.0.0           py37hc8dfbb8_2    conda-forge
six                       1.14.0                     py_1    conda-forge
sqlite                    3.30.1               hcee41ef_0    conda-forge
style                     1.1.0                    pypi_0    pypi
terminado                 0.8.3            py37hc8dfbb8_1    conda-forge
testpath                  0.4.4                      py_0    conda-forge
tk                        8.6.10               hed695b0_0    conda-forge
toolz                     0.10.0                     py_0    conda-forge
tornado                   6.0.4            py37h8f50634_1    conda-forge
traitlets                 4.3.3            py37hc8dfbb8_1    conda-forge
traittypes                0.2.1                      py_1    conda-forge
update                    0.0.1                    pypi_0    pypi
urllib3                   1.25.8                   pypi_0    pypi
wcwidth                   0.1.8                      py_0    conda-forge
webencodings              0.5.1                      py_1    conda-forge
wheel                     0.34.2                     py_1    conda-forge
widgetsnbextension        3.5.1                    py37_0    conda-forge
x264                      1!152.20180806       h14c3975_0    conda-forge
xlrd                      1.2.0                    pypi_0    pypi
xorg-kbproto              1.0.7             h14c3975_1002    conda-forge
xorg-libice               1.0.10               h516909a_0    conda-forge
xorg-libsm                1.2.3             h84519dc_1000    conda-forge
xorg-libx11               1.6.9                h516909a_0    conda-forge
xorg-libxau               1.0.9                h14c3975_0    conda-forge
xorg-libxdmcp             1.1.3                h516909a_0    conda-forge
xorg-libxext              1.3.4                h516909a_0    conda-forge
xorg-libxrender           0.9.10            h516909a_1002    conda-forge
xorg-renderproto          0.11.1            h14c3975_1002    conda-forge
xorg-xextproto            7.3.0             h14c3975_1002    conda-forge
xorg-xproto               7.0.31            h14c3975_1007    conda-forge
xz                        5.2.4             h14c3975_1001    conda-forge
yaml                      0.2.2                h516909a_1    conda-forge
zeromq                    4.3.2                he1b5a44_2    conda-forge
zipp                      3.1.0                      py_0    conda-forge
zlib                      1.2.11            h516909a_1006    conda-forge
zstandard                 0.13.0           py37he1b5a44_0    conda-forge
zstd                      1.4.4                h3b9ef0a_2    conda-forge
$ echo $JAVA_HOME
/usr/lib/jvm/java-8-openjdk-amd64

Of course, I am running all these commands in the conda environment (meaning: I have first activated the environment before running the above-mentioned commands)

Thank you for your help