pyimagej
pyimagej copied to clipboard
After OS Catalina Update, Invokespecial Instruction Error
I have a Python app that registers multiple images that worked prior to updating my Mac's OS to Catalina. After the update, I currently get the following error any time I try to register images or even make an image stack.
java.lang.VerifyError: Bad invokespecial instruction: current class isn't assignable to reference class.
Exception Details:
Location:
ij/gui/GenericDialog.show()V @1: invokespecial
Reason:
Error exists in the bytecode
Bytecode:
0x0000000: 2ab7 0311 2ab4 0314 9a00 0c13 0316 1303
0x0000010: 18b8 031b b1
Stackmap Table:
same_frame(@20)
at SIFT_ExtractPointRoi.run(SIFT_ExtractPointRoi.java:141)
at ij.IJ.runUserPlugIn(IJ.java:231)
at ij.IJ.runPlugIn(IJ.java:194)
at ij.Executer.runCommand(Executer.java:148)
at ij.Executer.run(Executer.java:66)
at ij.IJ.run(IJ.java:313)
at ij.IJ.run(IJ.java:324)
at ij.macro.Functions.doRun(Functions.java:625)
at ij.macro.Functions.doFunction(Functions.java:97)
at ij.macro.Interpreter.doStatement(Interpreter.java:275)
at ij.macro.Interpreter.doStatements(Interpreter.java:261)
at ij.macro.Interpreter.run(Interpreter.java:157)
at ij.macro.Interpreter.run(Interpreter.java:91)
at ij.macro.Interpreter.run(Interpreter.java:102)
at ij.plugin.Macro_Runner.runMacro(Macro_Runner.java:161)
at ij.IJ.runMacro(IJ.java:149)
at ij.IJ.runMacro(IJ.java:138)
at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1108)
at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1104)
at net.imagej.legacy.IJ1Helper.runMacroFriendly(IJ1Helper.java:1055)
at net.imagej.legacy.IJ1Helper.runMacro(IJ1Helper.java:1104)
at net.imagej.legacy.plugin.IJ1MacroEngine.eval(IJ1MacroEngine.java:147)
at org.scijava.script.ScriptModule.run(ScriptModule.java:160)
at org.scijava.module.ModuleRunner.run(ModuleRunner.java:168)
at org.scijava.module.ModuleRunner.call(ModuleRunner.java:127)
at org.scijava.module.ModuleRunner.call(ModuleRunner.java:66)
at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:228)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
I reinstalled JDK8 on my computer as I was originally having an issue that was mentioned here about the Java Runtime Error https://github.com/kivy/pyjnius/pull/441/commits/9700c47cd44ba51b55c593d42a21c0b110ed3deb
error. I resolved that by pip installing the latest commit of PyJNIus into my conda environment where pyimagej is located. Opening images and a few other basic commands seems to work ok, but others do not. Here is the contents of the .yaml file of my current conda environment that opens my app but fails when Fiji tries to run anything more than opening images.
name: pyimagej_app
channels:
- conda-forge
- defaults
dependencies:
- appnope=0.1.0=py37_1000
- asn1crypto=1.2.0=py37_0
- attrs=19.3.0=py_0
- backcall=0.1.0=py_0
- bleach=3.1.0=py_0
- blosc=1.17.0=h6de7cb9_1
- bokeh=1.4.0=py37_0
- bzip2=1.0.8=h01d97ff_1
- ca-certificates=2019.9.11=hecc5488_0
- certifi=2019.9.11=py37_0
- cffi=1.13.2=py37h33e799b_0
- chardet=3.0.4=py37_1003
- click=7.0=py_0
- cloudpickle=1.2.2=py_0
- cryptography=2.5=py37hdbc3d79_1
- curl=7.63.0=heae2a1f_1000
- cycler=0.10.0=py_2
- cytoolz=0.10.1=py37h0b31af3_0
- dask=2.8.0=py_1
- dask-core=2.8.0=py_0
- dbus=1.13.6=h2f22bb5_0
- decorator=4.4.1=py_0
- defusedxml=0.6.0=py_0
- dill=0.3.1.1=py37_0
- distributed=2.8.0=py_1
- entrypoints=0.3=py37_1000
- expat=2.2.5=h4a8c4bd_1004
- fastcache=1.1.0=py37h0b31af3_0
- freetype=2.10.0=h24853df_1
- fsspec=0.6.0=py_0
- gettext=0.19.8.1=h46ab8bc_1002
- git=2.19.1=pl526h28b1069_1001
- glib=2.58.3=py37h577aef8_1002
- gmp=6.1.2=h0a44026_1000
- gmpy2=2.1.0b1=py37h4160ff4_0
- h5py=2.10.0=nompi_py37h106b333_100
- hdf5=1.10.5=nompi_h3e39495_1104
- heapdict=1.0.1=py_0
- hyperspy=1.5.2=py37_0
- hyperspy-base=1.5.2=py37h01d97ff_0
- hyperspy-gui-ipywidgets=1.2=py_2
- hyperspy-gui-traitsui=1.2=py_0
- icu=58.2=h0a44026_1000
- idna=2.8=py37_1000
- imageio=2.6.1=py37_0
- imglyb=0.3.5=py37h5ca1d4c_0
- importlib_metadata=0.23=py37_0
- ipykernel=5.1.3=py37h5ca1d4c_0
- ipyparallel=6.2.4=py37_0
- ipython=7.9.0=py37h5ca1d4c_0
- ipython_genutils=0.2.0=py_1
- ipywidgets=7.5.1=py_0
- jedi=0.15.1=py37_0
- jgo=0.5.0=py37_0
- jinja2=2.10.3=py_0
- joblib=0.14.0=py_0
- jpeg=9c=h1de35cc_1001
- json5=0.8.5=py_0
- jsonschema=3.1.1=py37_0
- jupyter=1.0.0=py_2
- jupyter_client=5.3.3=py37_1
- jupyter_console=6.0.0=py_0
- jupyter_core=4.5.0=py_0
- jupyterlab=1.2.3=py_0
- jupyterlab_server=1.0.6=py_0
- kiwisolver=1.1.0=py37ha1b3eb9_0
- krb5=1.16.2=h24a3359_1000
- libblas=3.8.0=14_openblas
- libcblas=3.8.0=14_openblas
- libcurl=7.63.0=h76de61e_1000
- libcxx=9.0.0=h89e68fa_1
- libedit=3.1.20170329=hcfe32e1_1001
- libffi=3.2.1=h6de7cb9_1006
- libgfortran=4.0.0=2
- libiconv=1.15=h01d97ff_1005
- liblapack=3.8.0=14_openblas
- libllvm8=8.0.1=h770b8ee_0
- libopenblas=0.3.7=h4bb4525_3
- libpng=1.6.37=h2573ce8_0
- libsodium=1.0.17=h01d97ff_0
- libssh2=1.8.0=hf30b1f0_1003
- libtiff=4.1.0=ha78913b_1
- link-traits=1.0.2=py37_1002
- llvm-openmp=9.0.0=h40edb58_0
- llvmlite=0.30.0=py37h05045ef_1
- locket=0.2.0=py_2
- lz4-c=1.8.3=h6de7cb9_1001
- markupsafe=1.1.1=py37h0b31af3_0
- matplotlib=3.1.1=py37_2
- matplotlib-base=3.1.1=py37h11da6c2_2
- maven=3.6.0=0
- mistune=0.8.4=py37h0b31af3_1000
- more-itertools=7.2.0=py_0
- mpc=1.1.0=h4160ff4_1006
- mpfr=4.0.2=h44b798e_0
- mpmath=1.1.0=py_0
- mrcz=0.5.3=py37_0
- msgpack-python=0.6.2=py37ha1b3eb9_0
- natsort=6.2.0=py_0
- nbconvert=5.6.1=py37_0
- nbformat=4.4.0=py_1
- ncurses=6.1=h0a44026_1002
- networkx=2.4=py_0
- nodejs=12.4.0=h6de7cb9_0
- notebook=6.0.1=py37_0
- numba=0.46.0=py37h4f17bb1_1
- numexpr=2.7.0=py37h4f17bb1_0
- numpy=1.17.2=py37h6b0580a_0
- olefile=0.46=py_0
- openjdk=8.0.192=h1de35cc_1003
- openssl=1.0.2t=h1de35cc_0
- packaging=19.2=py_0
- pandas=0.25.3=py37h4f17bb1_0
- pandoc=2.7.3=0
- pandocfilters=1.4.2=py_1
- parso=0.5.1=py_0
- partd=1.0.0=py_0
- patsy=0.5.1=py_0
- pcre=8.43=h4a8c4bd_0
- perl=5.26.2=haec8ef5_1006
- pexpect=4.7.0=py37_0
- pickleshare=0.7.5=py37_1000
- pillow=5.3.0=py37hbddbef0_1000
- pint=0.9=py37_2
- pip=19.3.1=py37_0
- prometheus_client=0.7.1=py_0
- prompt_toolkit=2.0.10=py_0
- psutil=5.6.5=py37h0b31af3_0
- ptable=0.9.2=py_0
- ptyprocess=0.6.0=py_1001
- pycparser=2.19=py37_1
- pyface=6.1.2=py_0
- pygments=2.4.2=py_0
- pyopenssl=19.0.0=py37_0
- pyparsing=2.4.5=py_0
- pyqt=5.9.2=py37h2a560b1_4
- pyrsistent=0.15.5=py37h0b31af3_0
- pysocks=1.7.1=py37_0
- python=3.7.1=h145921a_1000
- python-blosc=1.8.1=py37h0a44026_0
- python-dateutil=2.8.1=py_0
- pytz=2019.3=py_0
- pywavelets=1.1.1=py37h3b54f70_0
- pyyaml=5.1.2=py37h0b31af3_0
- pyzmq=18.1.1=py37h4bf09a9_0
- qt=5.9.7=h93ee506_2
- qtconsole=4.5.5=py_0
- readline=7.0=hcfe32e1_1001
- requests=2.22.0=py37_1
- scikit-image=0.15.0=py37h86efe34_2
- scikit-learn=0.21.3=py37hd4ffd6c_0
- scipy=1.3.2=py37h82752d6_0
- scyjava=0.4.0=py37_0
- send2trash=1.5.0=py_0
- setuptools=41.6.0=py37_1
- sip=4.19.8=py37h0a44026_1000
- six=1.13.0=py37_0
- sortedcontainers=2.1.0=py_0
- sparse=0.8.0=py_0
- sqlite=3.28.0=h9721f7c_0
- statsmodels=0.10.1=py37h3b54f70_2
- sympy=1.4=py37_0
- tblib=1.4.0=py_0
- terminado=0.8.3=py37_0
- testpath=0.4.4=py_0
- tk=8.6.8=ha441bb4_1000
- toolz=0.10.0=py_0
- tornado=6.0.3=py37h0b31af3_0
- tqdm=4.38.0=py_0
- traitlets=4.3.3=py37_0
- traits=5.1.2=py37h0b31af3_1
- traitsui=6.1.3=py_0
- urllib3=1.25.7=py37_0
- wcwidth=0.1.7=py_1
- webencodings=0.5.1=py_1
- wheel=0.33.6=py37_0
- widgetsnbextension=3.5.1=py37_0
- xz=5.2.4=h1de35cc_1001
- yaml=0.1.7=h1de35cc_1001
- zeromq=4.3.2=h6de7cb9_2
- zict=1.0.0=py_0
- zipp=0.6.0=py_0
- zlib=1.2.11=h0b31af3_1006
- zstd=1.4.4=he7fca8b_1
- pip:
- cython==0.29.14
- opencv-python==4.1.1.26
- pyimagej==0.5.0
- pyjnius==1.2.1.dev0
- pysimplegui==4.6.0
Thank you for any help
@timoteoman3 The VerifyError
could indicate a problem with the byte-code patching of ImageJ1. Are you using the same Java component versions as on your previous system? You could try with newer/older versions of net.imagej:imagej
and/or net.imagej:ij
.
If you share your Python code, I can try to reproduce on my (Mojave) system.
So after a bit of looking I think part of the issue is that I had been using Java 6 as opposed to Java 8. When I tried to reinstall Java 6 after the Catalina update (which Mac doesn't like), there were a few errors caused. I now have one Mac with Catalina and one with Mojave, and I think I have some more time now to test what is working between the two. Right now my code has a lot of functions that manipulate strings to create a ImageJ macro so I'm going to hardcode a simple test case that does the same thing as my current code and see if it replicates the error and works on one machine and not the other. I'll post any significant updates here.
Also I am trying to avoid using net.imagej:imagej and just use a local FIJI since I always have an issue getting that to work on my Mac and I also need a custom plugin which I haven't figured out how to implement in PyImagej. I will try with other versions to see if I have any luck. Thank you.
Wow, I didn't know PyImageJ worked with Java 6. We never tested it. On my Mojave system, Apple Java 6 doesn't even work correctly—ImageJ won't even accept keyboard input anymore due to changes in Apple's APIs compared with the Apple Java 6 implementation. I hope you can use Java 8 instead?
Yeah since then I have switched over to Java 8 working on Mojave so hopefully I can get that fully set-up for Catalina as well with some trial and error. For Java 6, I only ever got PyImageJ to work with a call to the local distribution of FIJI and even then I was mostly required to run every command through a macro call. I haven't really tested any functionality since switching but maybe it will alleviate some of the previous issues.
Update: Good news and bad news. Good news is that I was able to get an aligned series of images once using pyimagej and an Anaconda environment on OS Catalina. Bad news is that I can't seem to replicate getting it to work from start to finish (or at all again). Here I have attached a small test case where I do a simple align of two Lena files using an affine transformation. Just cd into the test_imgs dir to make sure FIJI recognizes the paths.
The macro produces the same error submitted above when run from the terminal on OS Catalina in the Anaconda environment even though the macro runs perfectly fine in FIJI itself and in the same environment for OS Mojave. Like I said too, I DID manage to get it working once, but I can't seem to recreate that success.
import imagej
fiji = imagej.init('/Applications/Fiji.app')
print("FIJI installation: ", fiji.getVersion())
macro = """open("Lena_0.png");
open("Lena_1.png");
run("Images to Stack", "name=stack title=[] use");
run("Linear Stack Alignment with SIFT", "initial_gaussian_blur=1.60 steps_per_scale_octave=3 minimum_image_size=64 maximum_image_size=1200 feature_descriptor_size=4 feature_descriptor_orientation_bins=8 closest/next_closest_ratio=0.92 maximal_alignment_error=5 inlier_ratio=0.05 expected_transformation=Affine interpolate");"""
fiji.py.run_macro(macro)
Output:
FIJI installation: 2.0.0-rc-69/1.52t
java.lang.VerifyError: Bad invokespecial instruction: current class isn't assignable to reference class.
Exception Details:
Location:
ij/gui/GenericDialog.show()V @1: invokespecial
Reason:
Error exists in the bytecode
Bytecode:
0x0000000: 2ab7 0310 2ab4 0313 9a00 0c13 0315 1303
0x0000010: 17b8 031a b1
Stackmap Table:
same_frame(@20)
at ij.plugin.ImagesToStack.convertImagesToStack(ImagesToStack.java:86)
at ij.plugin.ImagesToStack.run(ImagesToStack.java:44)
at ij.IJ.runPlugIn(IJ.java:202)
at ij.Executer.runCommand(Executer.java:150)
at ij.Executer.run(Executer.java:68)
at ij.IJ.run(IJ.java:315)
at ij.IJ.run(IJ.java:326)
at ij.macro.Functions.doRun(Functions.java:625)
at ij.macro.Functions.doFunction(Functions.java:97)
at ij.macro.Interpreter.doStatement(Interpreter.java:275)
at ij.macro.Interpreter.doStatements(Interpreter.java:261)
at ij.macro.Interpreter.run(Interpreter.java:157)
at ij.macro.Interpreter.run(Interpreter.java:91)
at ij.macro.Interpreter.run(Interpreter.java:102)
at ij.plugin.Macro_Runner.runMacro(Macro_Runner.java:161)
at ij.IJ.runMacro(IJ.java:151)
at ij.IJ.runMacro(IJ.java:140)
at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1108)
at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1104)
at net.imagej.legacy.IJ1Helper.runMacroFriendly(IJ1Helper.java:1055)
at net.imagej.legacy.IJ1Helper.runMacro(IJ1Helper.java:1104)
at net.imagej.legacy.plugin.IJ1MacroEngine.eval(IJ1MacroEngine.java:147)
at org.scijava.script.ScriptModule.run(ScriptModule.java:160)
at org.scijava.module.ModuleRunner.run(ModuleRunner.java:168)
at org.scijava.module.ModuleRunner.call(ModuleRunner.java:127)
at org.scijava.module.ModuleRunner.call(ModuleRunner.java:66)
at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:228)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
java.lang.VerifyError: Bad invokespecial instruction: current class isn't assignable to reference class.
Exception Details:
Location:
ij/gui/GenericDialog.show()V @1: invokespecial
Reason:
Error exists in the bytecode
Bytecode:
0x0000000: 2ab7 0310 2ab4 0313 9a00 0c13 0315 1303
0x0000010: 17b8 031a b1
Stackmap Table:
same_frame(@20)
at SIFT_Align.run(SIFT_Align.java:140)
at ij.IJ.runUserPlugIn(IJ.java:233)
at ij.IJ.runPlugIn(IJ.java:196)
at ij.Executer.runCommand(Executer.java:150)
at ij.Executer.run(Executer.java:68)
at ij.IJ.run(IJ.java:315)
at ij.IJ.run(IJ.java:326)
at ij.macro.Functions.doRun(Functions.java:625)
at ij.macro.Functions.doFunction(Functions.java:97)
at ij.macro.Interpreter.doStatement(Interpreter.java:275)
at ij.macro.Interpreter.doStatements(Interpreter.java:261)
at ij.macro.Interpreter.run(Interpreter.java:157)
at ij.macro.Interpreter.run(Interpreter.java:91)
at ij.macro.Interpreter.run(Interpreter.java:102)
at ij.plugin.Macro_Runner.runMacro(Macro_Runner.java:161)
at ij.IJ.runMacro(IJ.java:151)
at ij.IJ.runMacro(IJ.java:140)
at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1108)
at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1104)
at net.imagej.legacy.IJ1Helper.runMacroFriendly(IJ1Helper.java:1055)
at net.imagej.legacy.IJ1Helper.runMacro(IJ1Helper.java:1104)
at net.imagej.legacy.plugin.IJ1MacroEngine.eval(IJ1MacroEngine.java:147)
at org.scijava.script.ScriptModule.run(ScriptModule.java:160)
at org.scijava.module.ModuleRunner.run(ModuleRunner.java:168)
at org.scijava.module.ModuleRunner.call(ModuleRunner.java:127)
at org.scijava.module.ModuleRunner.call(ModuleRunner.java:66)
at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:228)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
conda install command:
conda create -n ImageJ python=3.7.1 pip pyimagej openjdk=8
# Name Version Build Channel
bzip2 1.0.8 h0b31af3_2 conda-forge
ca-certificates 2019.11.28 hecc5488_0 conda-forge
certifi 2019.11.28 py37_0 conda-forge
cycler 0.10.0 py_2 conda-forge
freetype 2.10.0 h24853df_1 conda-forge
imglyb 0.4.0 py37h5ca1d4c_0 conda-forge
jgo 0.5.0 py37_0 conda-forge
kiwisolver 1.1.0 py37ha1b3eb9_0 conda-forge
libblas 3.8.0 14_openblas conda-forge
libcblas 3.8.0 14_openblas conda-forge
libcxx 9.0.1 1 conda-forge
libffi 3.2.1 h6de7cb9_1006 conda-forge
libgfortran 4.0.0 2 conda-forge
liblapack 3.8.0 14_openblas conda-forge
libopenblas 0.3.7 h3d69b6c_7 conda-forge
libpng 1.6.37 h2573ce8_0 conda-forge
llvm-openmp 9.0.1 h28b9765_2 conda-forge
matplotlib 3.1.3 py37_0 conda-forge
matplotlib-base 3.1.3 py37h11da6c2_0 conda-forge
maven 3.6.0 0 conda-forge
ncurses 6.1 h0a44026_1002 conda-forge
numpy 1.18.1 py37hde6bac1_0 conda-forge
openjdk 8.0.192 h0b31af3_1004 conda-forge
openssl 1.1.1d h0b31af3_0 conda-forge
pip 20.0.2 py_2 conda-forge
psutil 5.6.7 py37h0b31af3_0 conda-forge
pyimagej 0.5.0 py37_0 conda-forge
pyjnius 1.2.1 py37h47ef6d1_0 conda-forge
pyparsing 2.4.6 py_0 conda-forge
python 3.7.1 hbdd33cc_1003 conda-forge
python-dateutil 2.8.1 py_0 conda-forge
readline 7.0 hcfe32e1_1001 conda-forge
scyjava 0.4.0 py37_0 conda-forge
setuptools 45.1.0 py37_0 conda-forge
six 1.14.0 py37_0 conda-forge
sqlite 3.28.0 h9721f7c_0 conda-forge
tk 8.6.10 hbbe82c9_0 conda-forge
tornado 6.0.3 py37h0b31af3_0 conda-forge
wheel 0.34.2 py_1 conda-forge
xz 5.2.4 h1de35cc_1001 conda-forge
zlib 1.2.11 h0b31af3_1006 conda-forge
which java
returns .../anaconda3/envs/ImageJ/bin/java
java -version
returns
OpenJDK Runtime Environment (Zulu 8.33.0.1-macosx) (build 1.8.0_192-b01)
OpenJDK 64-Bit Server VM (Zulu 8.33.0.1-macosx) (build 25.192-b01, mixed mode
)
@trcote Sorry to drop the ball on replying back to this. Did you ever manage to get it working? If you're still seeing this problem with the latest versions of PyImageJ + ImageJ2, please reopen and I'll see if I can reproduce on my macOS machine.