pyimagej icon indicating copy to clipboard operation
pyimagej copied to clipboard

JVM required files

Open CanYing0913 opened this issue 1 year ago • 0 comments

What are the files required to start the JVM in jpype and use by pyimagej? I have a program and eventually I need to freeze it to executables (i.e., *.exe on Windows) using cx_freeze. This leads to the error below:

Process Process-1:
multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
  File "C:\Users\PC\mambaforge\envs\cz\lib\multiprocessing\pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "C:\Users\PC\mambaforge\envs\cz\lib\multiprocessing\pool.py", line 51, in starmapstar
    return list(itertools.starmap(args[0], args[1]))
  File "D:\CanYing\Code\CaImAn\src\src_stabilizer.py", line 22, in run_plugin
    ij = imagej.init(str(ijp), mode='headless')
  File "C:\Users\PC\mambaforge\envs\cz\lib\site-packages\imagej_init_.py", line 1211, in init
    success = _create_jvm(ij_dir_or_version_or_endpoint, mode, add_legacy)
  File "C:\Users\PC\mambaforge\envs\cz\lib\site-packages\imagej_init_.py", line 1312, in _create_jvm
    if hasattr(sj, "jvm_version") and sj.jvm_version()[0] >= 9:
  File "C:\Users\PC\mambaforge\envs\cz\lib\site-packages\scyjava_jvm.py", line 68, in jvm_version
    default_jvm_path = jpype.getDefaultJVMPath()
  File "C:\Users\PC\mambaforge\envs\cz\lib\site-packages\jpype_jvmfinder.py", line 74, in getDefaultJVMPath
    return finder.get_jvm_path()
  File "C:\Users\PC\mambaforge\envs\cz\lib\site-packages\jpype_jvmfinder.py", line 212, in get_jvm_path
    raise JVMNotFoundException("No JVM shared library file ({0}) "
jpype._jvmfinder.JVMNotFoundException: No JVM shared library file (jvm.dll) found. Try setting up the JAVA_HOME environment variable properly.

Note that the error was from my frozen application, (i.e. running my program from source code using cz mamba environment works perfectly). So, I begin to think if I can bring all JVM-related files with my application, (as if what JAVA_HOME points to in a mamba environment), so that I can directly point my JAVA_HOME environment variable to it, without worrying about it.

CanYing0913 avatar Jul 29 '24 06:07 CanYing0913