Pyimagj not initializing: libjvm.so not found

Hi everyone,
so I’m trying to run pyimagej (great idea, by the way). However, when I try to initialize ImageJ by:

ij = imagej.init()

after having imported imagej by:

import imagej

I get the following error:

Traceback (most recent call last):

  File "<ipython-input-10-ebc998cadaf9>", line 1, in <module>
    imagej.__version__

AttributeError: module 'imagej' has no attribute '__version__'


ij = imagej.init()
Traceback (most recent call last):

  File "<ipython-input-11-a1762181331d>", line 1, in <module>
    ij = imagej.init()

  File "/home/my_user/Programs/anaconda3/envs/pyimagej/lib/python3.7/site-packages/imagej/imagej.py", line 126, in init
    import imglyb

  File "/home/my_user/Programs/anaconda3/envs/pyimagej/lib/python3.7/site-packages/imglyb/__init__.py", line 38, in <module>
    config = _init_jvm_options()

  File "/home/my_user/Programs/anaconda3/envs/pyimagej/lib/python3.7/site-packages/imglyb/__init__.py", line 33, in _init_jvm_options
    import scyjava

  File "/home/my_user/Programs/anaconda3/envs/pyimagej/lib/python3.7/site-packages/scyjava/__init__.py", line 140, in <module>
    jnius = _init_jvm()

  File "/home/my_user/Programs/anaconda3/envs/pyimagej/lib/python3.7/site-packages/scyjava/__init__.py", line 131, in _init_jvm
    import jnius

  File "/home/my_user/Programs/anaconda3/envs/pyimagej/lib/python3.7/site-packages/jnius/__init__.py", line 42, in <module>
    from .reflect import *  # noqa

  File "/home/my_user/Programs/anaconda3/envs/pyimagej/lib/python3.7/site-packages/jnius/reflect.py", line 17, in <module>
    class Class(with_metaclass(MetaJavaClass, JavaClass)):

  File "/home/my_user/Programs/anaconda3/envs/pyimagej/lib/python3.7/site-packages/six.py", line 856, in __new__
    return meta(name, resolved_bases, d)

  File "jnius/jnius_export_class.pxi", line 114, in jnius.MetaJavaClass.__new__

  File "jnius/jnius_export_class.pxi", line 164, in jnius.MetaJavaClass.resolve_class

  File "jnius/jnius_env.pxi", line 11, in jnius.get_jnienv

  File "jnius/jnius_jvm_dlopen.pxi", line 118, in jnius.get_platform_jnienv

  File "jnius/jnius_jvm_dlopen.pxi", line 87, in jnius.create_jnienv

SystemError: Error calling dlopen(b'/home/my_user/Programs/anaconda3/envs/pyimagej/lib/server/libjvm.so': b'/home/my_user/Programs/anaconda3/envs/pyimagej/lib/server/libjvm.so: cannot open shared object file: No such file or directory'

My context:

-Installed pyimagej through conda by:

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

Hence, I have an Anaconda environment called pyimagej.

I’m running Ubuntu 20.04.

Has anyone encountered a similar problem? I’m assuming that it’s a problem with the JVM, but I’m not sure, neither I know how to work around it. All help is appreciated :slight_smile:

@mpinkert @ctrueden any ideas? Again, great work and idea! Kudos!

Sorry for the delay in reply, @Jorge_Cordero_Gonzal. We are approaching a new release of PyImageJ, which substantially changes how the Java bridge works under the hood. I’ll reply back here again once that release is ready for you to test; hopefully it will eliminate the issues you are seeing now.

3 Likes

Thanks for your reply @ctrueden!
Looking forward to see the new release :slight_smile:

@Jorge_Cordero_Gonzal I released pyimagej 1.0.0 to PyPI. It should propagate to conda-forge in the next few hours. Please test and let us know how it goes! :crossed_fingers: