I have a program that uses pyimagej in a python script for multiple image processing steps. The program runs fine and I want to make it available to the users on windows as a .exe program, bundled with all its dependencies.
I can create such a bundle on macOS by using:
pyinstaller -p fork-stitcher --add-data '/miniconda3/envs/fork_stitcher/share/pyjnius/pyjnius.jar:./share/pyjnius/' fork-stitcher/run_stitching_batches.py
(I need to manually add the pyjnius JAR file, then it runs). This program then runs and performs the task. But I need this to run on Windows, which is where I run into difficulties.
The python script itself runs fine on my Windows machine, but when I package it up with pyinstaller, I run into issues.
- By default, it can’t find the jre folder. So I tried to add this as a datafile, like this:
And set the javapath in my pythonscript to it:
os.environ['JAVA_HOME'] = '.\\share'
Then, it has an issue because maven is not found on the PATH:
jgo.jgo.ExecutableNotFound: mvn not found on path ....
So I also add Maven to the files that are added (this bin folder is where the script gets maven from when run directly, so I included the whole folder):
And add it to the PATH variable:
os.environ['PATH'] += os.pathsep + '.\\share\\bin'
After that, it doesn’t complain about not finding maven anymore, but now has the following:
INFO Failed to bootstrap the artifact. INFO Possible solutions: INFO * Double check the endpoint for correctness (https://search.maven.org/). INFO * Add needed repositories to ~/.jrunrc [repositories] block (see README). INFO * Try with an explicit version number (release metadata might be wrong). Traceback .... File "site-packages\jgo\jgo.py", line 203, in run_and_combine_outputs ... subprocessed.CalledProcessError: Command mvn.CMD -B -f pathToFijiInstance (in .jgo folder) dependenc:resolve returned a non-zero exit status 1.
Does anyone have an idea on how I get around this? Or how I correctly package up a script using pyimage with all its dependencies? I’m open to alternative approaches, but could only find pyinstaller and py2exe (which does not support Python 3.7). Is there a way to install the java dependencies correctly to that package instead of my approach of adding the things that made the program crash?
@ctrueden Maybe you could come to the rescue once more? I saw this issue that also has the
Failed to bootstrap the artifact. message, so maybe that’s related? But I can’t follow the solution as discussed there.
(sorry, I can’t copy the error message, because it crashes just after showing it. Here’s a picture of it)