Analysis with ImageJ and Visualization in the Jupyter Notebook

fiji
visualization
imagej
python
imagej-ops
jupyter

#21

Can you successfully import imglyb (without importing any imagej) in that conda environment?


#22

No, I can’t. It raises the same error.

ImportError: DLL load failed: The specified module could not be found.

I tried reinstalling from the terminal but still doesn’t work.

activate imglyb
(imglyb) C:\Users\User>conda install -c hanslovsky imglib2-imglyb   

#23

The issue is with the conda build of PyJNIus. I tried on a Windows laptop and I got the same error. I tried to build the conda package for PyJNIus again on Windows but it failed with the same error. Unfortunately, my windows knowledge and debugging skill is very limited. It already took me hours to get conda to (try and) build, so I cannot help here, unfortunately.


#24

Until we find maintainers for the conda packages for Windows, I will not be able to provide PyJNIus on conda, unfortunately. The only other option would be to try and build PyJNIus yourself. My hope is that you could run imglyb then.


#25

As stated in the other thread (Imglyb and PyJNIus conda package maintainers needed for Windows and OSX) it seems like I was able to fix the build issues on windows with the help of @jakirkham and @jjahanip
PyJNIus (and eventually imglyb) will be available on conda-forge (instead of my personal channel):
https://github.com/conda-forge/staged-recipes/pull/6091
@malj390 I will also update my anaconda channel tonight (when I have access to a Windows machine) with an updated Windows conda package, which should hopefully fix your particular issue for now.


#26

@malj390 I just updated the imglib2-imglyb and imglyb-examples packages on my conda channel hanslovsky. I confirmed on a Windows 10 machine that it works. Please let me know if there are any issues.


#27

Hi @hanslovsky, sorry to bump this thread again - I came here while trying to troubleshoot similar errors.

Like malj300 I too can’t seem to initialize an imagej instance. I’m unable to import imglyb, and while I am able to import imagej I cannot initialize it. Below I’ve copied the errors I’m getting, have you come across these before?

import imagej

ij = imagej.init('C:\\Users\\Bojing\\Fiji.app')
Traceback (most recent call last):

  File "<ipython-input-11-9a0f3b566862>", line 1, in <module>
    ij = imagej.init('C:\\Users\\Bojing\\Fiji.app')

  File "C:\ProgramData\Anaconda3\lib\site-packages\imagej-0.2.0-py3.6.egg\imagej\imagej.py", line 196, in init
    jnius_config.add_options('-Djava.awt.headless=true')

  File "C:\ProgramData\Anaconda3\lib\site-packages\jnius_config.py", line 26, in add_options
    raise ValueError("VM is already running, can't set options")

ValueError: VM is already running, can't set options

import imglyb
Traceback (most recent call last):

  File "<ipython-input-9-821e397e0338>", line 1, in <module>
    import imglyb

  File "C:\ProgramData\Anaconda3\lib\site-packages\imglyb\__init__.py", line 71, in <module>
    config = _init_jvm_options()

  File "C:\ProgramData\Anaconda3\lib\site-packages\imglyb\__init__.py", line 27, in _init_jvm_options
    IMGLYB_JAR_CACHE_DIR    = os.path.join(os.getenv('HOME'), '.imglyb-jars')

  File "C:\ProgramData\Anaconda3\lib\ntpath.py", line 76, in join
    path = os.fspath(path)

TypeError: expected str, bytes or os.PathLike object, not NoneType

#28

The first issue is not an imglyb issue and I cannot help with that. It might be worth checking out the imagej.py github repo and opening an issue if appropriate.

The second issue seems to be a bug introduced in recent changes in imglyb: Windows does not seem to define a HOME environment variable and you seem to be the first Windows user to use imglyb since those changes.
Try replacing

os.getenv('HOME')

with

os.path.expanduser('~')

at
imglyb/__init__.py#L27 and imglyb/__init__.py#L28
If that works, I will add a patch and this will be fixed in the next release.


#29

@batlike
imglib/imglyb#2 is ready for a merge, once you confirm the fix.


#30

Thanks @hanslovsky! It’s true I no longer get that error thanks to your suggestion. But like malj390 and bnorthan, I continue to have difficulty with environment variables and paths. I actually followed one of your tutorials on Github, namely on imglyb - but even after creating those environment variables, I continue to get these errors:

When I import imglyb I get

import imglyb
Path to pyjnius.jar not defined! Use environment variable PYJNIUS_JAR to define it.

When I initialize an imagej instance, I get

import imagej

ij = imagej.init('C:\\Users\\Bojing\\Fiji.app')
please set the java enviroment manully by call set_java_env() command
Java can not be found, it might not be correctly installed.
Added 386 JARs to the Java classpath.
Traceback (most recent call last):

  File "<ipython-input-3-9a0f3b566862>", line 1, in <module>
    ij = imagej.init('C:\\Users\\Bojing\\Fiji.app')

  File "C:\ProgramData\Anaconda3\lib\site-packages\imagej-0.2.0-py3.6.egg\imagej\imagej.py", line 204, in init
    import imglyb

  File "C:\ProgramData\Anaconda3\lib\site-packages\imglyb\__init__.py", line 59, in <module>
    from .imglib_ndarray import ImgLibReferenceGuard as _ImgLibReferenceGuard

  File "C:\ProgramData\Anaconda3\lib\site-packages\imglyb\imglib_ndarray.py", line 2, in <module>
    from imglyb import util

  File "C:\ProgramData\Anaconda3\lib\site-packages\imglyb\util.py", line 23, in <module>
    Helpers = autoclass('net.imglib2.python.Helpers')

  File "C:\ProgramData\Anaconda3\lib\site-packages\jnius\reflect.py", line 159, in autoclass
    c = find_javaclass(clsname)

  File "jnius\jnius_export_func.pxi", line 26, in jnius.find_javaclass

JavaException: Class not found b'net/imglib2/python/Helpers'

#31

I wonder if there is something I’m not understanding with the set_java_env function under imagej. Even when I state

imagej.set_java_env("C:\\Program Files\\Java\\jdk1.8.0_181")

when I initialize ij= imagej.init(…) it cannot find Java. Am I using this function correctly…?


#32

Did you install pyjnius through conda or did you build it yourself? In the latter case, if you followed the instructions on imglyb, setting up the environment is only documented for Linux/OSX (again, not a Windows developer here). In that case, please try

  1. using pyjnius from conda-forge: conda install -c conda-forge pyjnius, or
  2. setting the PYJNIUS_JAR environment with the appropriate command on windows

If the latter works, I will update the README.md accordingly.

Regarding your second problem, again I am not involved in the development of imagej.py but maybe @ctrueden can help.
This could be relevant, too:


#33

I built pyjnius through conda (ie. conda install -c hanslovsky pyjnius). Sorry I’m slow to respond, I will give this a try this weekend.

Thanks for your response, and I will update what I find.


#34

My conda build for pyjnius migrated to conda-forge and those to builds are probably not 100% identical. To install it, run

conda install -c conda-forge pyjnius

Maybe that minor detail is the issue here. I will try to confirm on a windows machine and subsequently

  • remove pyjnius from my anaconda channel, and
  • add instructions to install pyjnius from conda-forge to the imglyb readme.

Update: I tried with pyjnius from my anaconda channel and it worked. @batlike, please share

  • your windows version,
  • how you run the code snippet that fails (Windows cmd, IDE, …),
  • and the ouput of these commands with the correct conda environment activated (example output after each command):
conda env list
# conda environments:
#
base                     C:\Users\phili\Miniconda3
imglib2-pyjnius-test  *  C:\Users\phili\Miniconda3\envs\imglib2-pyjnius-test
conda install -c hanslovsky pyjnius
C:\Users\phili\Miniconda3\envs\imglib2-pyjnius-test
python -c "import sys; print(sys.executable)"
C:\Users\phili\Miniconda3\envs\imglib2-pyjnius-test\python.exe
conda list
# packages in environment at C:\Users\phili\Miniconda3\envs\imglib2-pyjnius-test:
#
# Name                    Version                   Build  Channel
blas                      1.0                         mkl
certifi                   2018.8.24                py36_1
icc_rt                    2017.0.4             h97af966_0
intel-openmp              2019.0                      118
jrun                      0.1.0dev                   py_3    hanslovsky
mkl                       2019.0                      118
mkl_fft                   1.0.6            py36hdbbee80_0
mkl_random                1.0.1            py36h77b88f5_1
numpy                     1.15.2           py36ha559c80_0
numpy-base                1.15.2           py36h8128ebf_0
openjdk                   8.0.152              h7382acf_1
pip                       10.0.1                   py36_0
pyjnius                   1.1.1.post54     py36h6538335_0    hanslovsky
python                    3.6.6                hea74fb7_0
setuptools                40.2.0                   py36_0
six                       1.11.0                   py36_1
vc                        14.1                 h0510ff6_4
vs2015_runtime            14.15.26706          h3a45250_0
wheel                     0.31.1                   py36_0
wincertstore              0.2              py36h7fe50ca_0
python -c "import jnius; print(jnius)"
<module 'jnius' from 'C:\\Users\\phili\\Miniconda3\\envs\\imglib2-pyjnius-test\\lib\\site-packages\\jnius\\__init__.py'>
echo %PYJNIUS_JAR%
C:\Users\phili\Miniconda3\envs\imglib2-pyjnius-test\share\pyjnius\pyjnius.jar

#35

Please note that I have never (that I can recall) tested imagej.py on Windows. The issue linked by @hanslovsky above likely fixes one Windows-related problem; there may be still be others.

Would you be willing to test out the file-separators branch? I do not want to merge it until some Windows user tells me it improves the situation…


#36
  • My Windows specifications:

Edition: Windows 10 Pro
Version: 1803
OS build: 17134.285

  • how I run the code snippet
    -> I currently run the example code (pasted below) in Spyder (Python 3.6). To debug, I ran it line by line, and I get an error the moment I try to initialize ij (2nd line)
import imagej
ij = imagej.init('C:\\Users\\Bojing\\Fiji.app')

# Import an image with scikit-image.
import skimage
from skimage import io
# NB: Blood vessel image from: https://www.fi.edu/heart/blood-vessels
img = io.imread('https://www.fi.edu/sites/fi.live.franklinds.webair.com/files/styles/featured_large/public/General_EduRes_Heart_BloodVessels_0.jpg')
import numpy as np
img = np.mean(img, axis=2)

# Invoke ImageJ's Frangi vesselness op.
vessels = np.zeros(img.shape, dtype=img.dtype)
import imglyb
ij.op().filter().frangiVesselness(imglyb.to_imglib(vessels), imglyb.to_imglib(img), [1, 1], 20)

Even when I explicitly set the Java environment, I still get the same error (Java cannot be found)

import imagej
imagej.set_java_env("C:\\Program Files\\Java\\jdk1.8.0_181")
imagej.set_imglyb_env("C:\\ProgramData\\Anaconda3\\pkgs\\imglib2-imglyb-0.0.0.post135-py36_0\\share\\imglyb\\imglib2-imglyb-0.1.0-SNAPSHOT.jar")
imagej.set_pyjnius_env("C:\\ProgramData\\Anaconda3\\pkgs\\pyjnius-1.1.1.post54-py36h6538335_0\\share\\pyjnius\\pyjnius.jar")
ij = imagej.init('C:\\Users\\Bojing\\Fiji.app')

--

ij = imagej.init('C:\\Users\\Bojing\\Fiji.app')
please set the java enviroment manully by call set_java_env() command
Java can not be found, it might not be correctly installed.
Added 386 JARs to the Java classpath.
Traceback (most recent call last):

  File "<ipython-input-5-9a0f3b566862>", line 1, in <module>
    ij = imagej.init('C:\\Users\\Bojing\\Fiji.app')

  File "C:\ProgramData\Anaconda3\lib\site-packages\imagej-0.2.0-py3.6.egg\imagej\imagej.py", line 204, in init
    import imglyb

  File "C:\ProgramData\Anaconda3\lib\site-packages\imglyb\__init__.py", line 59, in <module>
    from .imglib_ndarray import ImgLibReferenceGuard as _ImgLibReferenceGuard

  File "C:\ProgramData\Anaconda3\lib\site-packages\imglyb\imglib_ndarray.py", line 2, in <module>
    from imglyb import util

  File "C:\ProgramData\Anaconda3\lib\site-packages\imglyb\util.py", line 23, in <module>
    Helpers = autoclass('net.imglib2.python.Helpers')

  File "C:\ProgramData\Anaconda3\lib\site-packages\jnius\reflect.py", line 159, in autoclass
    c = find_javaclass(clsname)

  File "jnius\jnius_export_func.pxi", line 26, in jnius.find_javaclass

JavaException: Class not found b'net/imglib2/python/Helpers'
  • the outputs of the commands with the correct environment activated:
(base) C:\WINDOWS\system32>conda install -c conda-forge pyjnius
Solving environment: done

## Package Plan ##

  environment location: C:\ProgramData\Anaconda3

  added / updated specs:
    - pyjnius


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    pyjnius-1.1.1.post54       |   py36h6538335_0         182 KB  conda-forge

The following NEW packages will be INSTALLED:

    pyjnius:         1.1.1.post54-py36h6538335_0 conda-forge

The following packages will be UPDATED:

    ca-certificates: 2018.03.07-0                            --> 2018.8.24-ha4d7672_0 conda-forge
    certifi:         2018.8.24-py36_1                        --> 2018.8.24-py36_1001  conda-forge
    conda:           4.5.11-py36_0                           --> 4.5.11-py36_0        conda-forge
    openssl:         1.0.2p-hfa6e2cd_0                       --> 1.0.2p-hfa6e2cd_1000 conda-forge

Proceed ([y]/n)? y


Downloading and Extracting Packages
pyjnius-1.1.1.post54 | 182 KB    | ############################################################################ | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done

(base) C:\WINDOWS\system32>SET PATH_BACKUP=''

(base) C:\WINDOWS\system32>set "JAVA_HOME="

(base) C:\WINDOWS\system32>set "JAVA_HOME_CONDA_BACKUP="

(base) C:\WINDOWS\system32>set "JAVA_HOME=C:\ProgramData\Anaconda3\Library"

(base) C:\WINDOWS\system32>SET "PYJNIUS_JAR_BACKUP=C:\ProgramData\Anaconda3\pkgs\pyjnius-1.1.1.post54-py36h6538335_0\share\pyjnius\pyjnius.jar"

(base) C:\WINDOWS\system32>SET "PYJNIUS_JAR=C:\ProgramData\Anaconda3\share\pyjnius\pyjnius.jar"

(base) C:\WINDOWS\system32>SET "JDK_HOME_BACKUP=C:\Program Files\Java\jdk1.8.0_181\"

(base) C:\WINDOWS\system32>SET "JDK_HOME=C:\ProgramData\Anaconda3\Library"

(base) C:\WINDOWS\system32>SET "PATH_BACKUP=C:\ProgramData\Anaconda3\Library\jre\bin\server;C:\ProgramData\Anaconda3\Library\bin;C:\ProgramData\Anaconda3;C:\ProgramData\Anaconda3\Library\mingw-w64\bin;C:\ProgramData\Anaconda3\Library\usr\bin;C:\ProgramData\Anaconda3\Library\bin;C:\ProgramData\Anaconda3\Scripts;C:\ProgramData\Anaconda3\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.2\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.2\libnvvp;C:\ProgramData\Anaconda3;C:\ProgramData\Anaconda3\Library\mingw-w64\bin;C:\ProgramData\Anaconda3\Library\usr\bin;C:\ProgramData\Anaconda3\Library\bin;C:\ProgramData\Anaconda3\Scripts;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\dotnet\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Git\cmd;C:\Program Files\PuTTY\;C:\Program Files\WIDCOMM\Bluetooth Software\;C:\Program Files\WIDCOMM\Bluetooth Software\syswow64;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Java\jdk1.8.0_181\bin`;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Users\Bojing\AppData\Local\Microsoft\WindowsApps;C:\Users\Bojing\AppData\Local\GitHubDesktop\bin;C:\Users\Bojing\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Java\jdk1.8.0_181\jre\bin\server\"

(base) C:\WINDOWS\system32>SET "PATH=C:\ProgramData\Anaconda3\Library\jre\bin\server;C:\ProgramData\Anaconda3\Library\bin;C:\ProgramData\Anaconda3\Library\jre\bin\server;C:\ProgramData\Anaconda3\Library\bin;C:\ProgramData\Anaconda3;C:\ProgramData\Anaconda3\Library\mingw-w64\bin;C:\ProgramData\Anaconda3\Library\usr\bin;C:\ProgramData\Anaconda3\Library\bin;C:\ProgramData\Anaconda3\Scripts;C:\ProgramData\Anaconda3\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.2\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.2\libnvvp;C:\ProgramData\Anaconda3;C:\ProgramData\Anaconda3\Library\mingw-w64\bin;C:\ProgramData\Anaconda3\Library\usr\bin;C:\ProgramData\Anaconda3\Library\bin;C:\ProgramData\Anaconda3\Scripts;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\dotnet\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Git\cmd;C:\Program Files\PuTTY\;C:\Program Files\WIDCOMM\Bluetooth Software\;C:\Program Files\WIDCOMM\Bluetooth Software\syswow64;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Java\jdk1.8.0_181\bin`;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Users\Bojing\AppData\Local\Microsoft\WindowsApps;C:\Users\Bojing\AppData\Local\GitHubDesktop\bin;C:\Users\Bojing\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Java\jdk1.8.0_181\jre\bin\server\"

(base) C:\WINDOWS\system32>python -c "import jnius; print(jnius)"
<module 'jnius' from 'C:\\ProgramData\\Anaconda3\\lib\\site-packages\\jnius\\__init__.py'>

(base) C:\WINDOWS\system32>echo %PYJNIUS_JAR%
C:\ProgramData\Anaconda3\share\pyjnius\pyjnius.jar

(base) C:\WINDOWS\system32>conda list
# packages in environment at C:\ProgramData\Anaconda3:
#
# Name                    Version                   Build  Channel
_ipyw_jlab_nb_ext_conf    0.1.0                    py36_0
_tflow_190_select         0.0.1                       gpu    anaconda
absl-py                   0.4.1                    py36_0
alabaster                 0.7.11                   py36_0
anaconda-client           1.7.2                    py36_0
anaconda-navigator        1.8.7                    py36_0
anaconda-project          0.8.2                    py36_0
appdirs                   1.4.3            py36h28b3542_0
asn1crypto                0.24.0                   py36_0
astor                     0.7.1                    py36_0
astroid                   2.0.4                    py36_0
astropy                   3.0.4            py36hfa6e2cd_0
atomicwrites              1.2.1                    py36_0
attrs                     18.2.0           py36h28b3542_0
automat                   0.7.0                    py36_0
babel                     2.6.0                    py36_0
backcall                  0.1.0                    py36_0
backports                 1.0                      py36_1
backports.shutil_get_terminal_size 1.0.0                    py36_2
beautifulsoup4            4.6.3                    py36_0
bitarray                  0.8.3            py36hfa6e2cd_0
bkcharts                  0.2              py36h7e685f7_0
blas                      1.0                         mkl
blaze                     0.11.3                   py36_0
bleach                    2.1.4                    py36_0
blosc                     1.14.3               he51fdeb_0
bokeh                     0.13.0                   py36_0
boto                      2.49.0                   py36_0
bottleneck                1.2.1            py36h452e1ab_1
bzip2                     1.0.6                hfa6e2cd_5
ca-certificates           2018.8.24            ha4d7672_0    conda-forge
certifi                   2018.8.24             py36_1001    conda-forge
cffi                      1.11.5           py36h74b6da3_1
chardet                   3.0.4                    py36_1
click                     6.7              py36hec8c647_0
cloudpickle               0.5.5                    py36_0
clyent                    1.2.2                    py36_1
colorama                  0.3.9            py36h029ae33_0
comtypes                  1.1.7                    py36_0
conda                     4.5.11                   py36_0    conda-forge
conda-build               3.15.1                   py36_0
conda-env                 2.6.0                h36134e3_1
conda-verify              3.1.0                    py36_0
console_shortcut          0.1.1                h6bb2dd7_3
constantly                15.1.0           py36h28b3542_0
contextlib2               0.5.5            py36he5d52c0_0
cryptography              2.3.1            py36h74b6da3_0
cudatoolkit               9.0                           1    anaconda
cudnn                     7.1.4                 cuda9.0_0    anaconda
curl                      7.60.0               h7602738_0
cycler                    0.10.0           py36h009560c_0
cython                    0.28.5           py36h6538335_0
cytoolz                   0.9.0.1          py36hfa6e2cd_1
dask                      0.19.1                   py36_0
dask-core                 0.19.1                   py36_0
datashape                 0.5.4                    py36_1
decorator                 4.3.0                    py36_0
defusedxml                0.5.0                    py36_1
distributed               1.23.1                   py36_0
docutils                  0.14             py36h6012d8f_0
entrypoints               0.2.3                    py36_2
et_xmlfile                1.0.1            py36h3d2d736_0
fastcache                 1.0.2            py36hfa6e2cd_2
filelock                  3.0.8                    py36_0
flask                     1.0.2                    py36_1
flask-cors                3.0.6                    py36_0
freetype                  2.8                  h51f8f2c_1
future                    0.16.0                   py36_2
gast                      0.2.0                    py36_0
get_terminal_size         1.0.0                h38e98db_0
gevent                    1.3.6            py36hfa6e2cd_0
glob2                     0.6                      py36_0
greenlet                  0.4.15           py36hfa6e2cd_0
grpcio                    1.12.1           py36h1a1b453_0
h5py                      2.8.0            py36h3bdd7fb_2
hdf5                      1.10.2               hac2f561_1
heapdict                  1.0.0                    py36_2
html5lib                  1.0.1                    py36_0
hyperlink                 18.0.0                   py36_0
icc_rt                    2017.0.4             h97af966_0
icu                       58.2                 ha66f8fd_1
idna                      2.7                      py36_0
imageio                   2.4.1                    py36_0
imagesize                 1.1.0                    py36_0
incremental               17.5.0                   py36_0
intel-openmp              2018.0.0                      8
ipykernel                 4.9.0                    py36_1
ipython                   6.5.0                    py36_0
ipython_genutils          0.2.0            py36h3c5d0ee_0
ipywidgets                7.4.1                    py36_0
isort                     4.3.4                    py36_0
itsdangerous              0.24                     py36_1
jdcal                     1.4                      py36_0
jedi                      0.12.1                   py36_0
jinja2                    2.10                     py36_0
jnius                     1.1.0                     <pip>
jpeg                      9b                   hb83a4c4_2
jrun                      0.1.0dev                   py_3    hanslovsky
jsonschema                2.6.0            py36h7636477_0
jupyter                   1.0.0                    py36_7
jupyter_client            5.2.3                    py36_0
jupyter_console           5.2.0                    py36_1
jupyter_core              4.4.0                    py36_0
jupyterlab                0.34.9                   py36_0
jupyterlab_launcher       0.13.1                   py36_0
keyring                   13.2.1                   py36_0
kiwisolver                1.0.1            py36h6538335_0
lazy-object-proxy         1.3.1            py36hfa6e2cd_2
libcurl                   7.60.0               hc4dcbb0_0
libiconv                  1.15                 h1df5818_7
libpng                    1.6.34               h79bbb47_0
libprotobuf               3.5.2                he0781b1_0    anaconda
libsodium                 1.0.16               h9d3ae62_0
libssh2                   1.8.0                hd619d38_4
libtiff                   4.0.9                hb8ad9f9_1
libxml2                   2.9.8                hadb2253_1
libxslt                   1.1.32               hf6f1972_0
llvmlite                  0.24.0           py36h6538335_0
locket                    0.2.0            py36hfed976d_1
lxml                      4.2.5            py36hef2cd61_0
lzo                       2.10                 h6df0209_2
m2w64-gcc-libgfortran     5.3.0                         6
m2w64-gcc-libs            5.3.0                         7
m2w64-gcc-libs-core       5.3.0                         7
m2w64-gmp                 6.1.0                         2
m2w64-libwinpthread-git   5.0.0.4634.697f757               2
markdown                  2.6.11                   py36_0
markupsafe                1.0              py36hfa6e2cd_1
matplotlib                2.2.2            py36h153e9ff_1
mccabe                    0.6.1                    py36_1
menuinst                  1.4.14           py36hfa6e2cd_0
mistune                   0.8.3            py36hfa6e2cd_1
mkl                       2018.0.2                      1
mkl-service               1.1.2            py36hb217b18_4
mkl_fft                   1.0.1            py36h452e1ab_0
mkl_random                1.0.1            py36h9258bd6_0
more-itertools            4.3.0                    py36_0
mpmath                    1.0.0                    py36_2
msgpack-python            0.5.6            py36he980bc4_1
msys2-conda-epoch         20160418                      1
multipledispatch          0.6.0                    py36_0
navigator-updater         0.2.1                    py36_0
nbconvert                 5.4.0                    py36_1
nbformat                  4.4.0            py36h3a5bc1b_0
networkx                  2.1                      py36_0
nltk                      3.3.0                    py36_0
nose                      1.3.7                    py36_2
notebook                  5.6.0                    py36_0
numba                     0.39.0           py36h830ac7b_0
numexpr                   2.6.5            py36hcd2f87e_0
numpy                     1.14.3           py36h9fa60d3_1
numpy-base                1.14.3           py36h555522e_1
numpydoc                  0.8.0                    py36_0
odo                       0.5.1            py36h7560279_0
olefile                   0.46                     py36_0
openjdk                   8.0.152              h7382acf_1
openpyxl                  2.5.6                    py36_0
openssl                   1.0.2p            hfa6e2cd_1000    conda-forge
packaging                 17.1                     py36_0
pandas                    0.23.4           py36h830ac7b_0
pandoc                    1.19.2.1             hb2460c7_1
pandocfilters             1.4.2                    py36_1
parso                     0.3.1                    py36_0
partd                     0.3.8            py36hc8e763b_0
path.py                   11.1.0                   py36_0
pathlib2                  2.3.2                    py36_0
patsy                     0.5.0                    py36_0
pdfminer.six              20170720                  <pip>
pep8                      1.7.1                    py36_0
pickleshare               0.7.4            py36h9de030f_0
pillow                    5.1.0            py36h0738816_0
pip                       10.0.1                   py36_0
pip                       18.0                      <pip>
pkginfo                   1.4.2                    py36_1
pluggy                    0.7.1            py36h28b3542_0
ply                       3.11                     py36_0
prometheus_client         0.3.1            py36h28b3542_0
prompt_toolkit            1.0.15           py36h60b8f86_0
protobuf                  3.5.2            py36h6538335_1
psutil                    5.4.7            py36hfa6e2cd_0
py                        1.6.0                    py36_0
pyasn1                    0.4.4            py36h28b3542_0
pyasn1-modules            0.2.2                    py36_0
pycodestyle               2.4.0                    py36_0
pycosat                   0.6.3            py36hfa6e2cd_0
pycparser                 2.18                     py36_1
pycrypto                  2.6.1            py36hfa6e2cd_9
pycryptodome              3.6.5                     <pip>
pycurl                    7.43.0.2         py36h74b6da3_0
pyflakes                  2.0.0                    py36_0
pygments                  2.2.0            py36hb010967_0
pyhamcrest                1.9.0                      py_2    conda-forge
pyjnius                   1.1.1.post54     py36h6538335_0    conda-forge
pylint                    2.1.1                    py36_0
pyodbc                    4.0.24           py36h6538335_0
pyopenssl                 18.0.0                   py36_0
pyparsing                 2.2.0                    py36_1
pyqt                      5.9.2            py36h1aa27d4_0
pysocks                   1.6.8                    py36_0
pytables                  3.4.4            py36he6f6034_0
pytest                    3.8.0                    py36_0
pytest-arraydiff          0.2              py36h39e3cac_0
pytest-astropy            0.4.0                    py36_0
pytest-doctestplus        0.1.3                    py36_0
pytest-openfiles          0.3.0                    py36_0
pytest-remotedata         0.3.0                    py36_0
python                    3.6.6                hea74fb7_0
python-dateutil           2.7.3                    py36_0
pytz                      2018.5                   py36_0
pywavelets                1.0.0            py36h452e1ab_0
pywin32                   223              py36hfa6e2cd_1
pywinpty                  0.5.4                    py36_0
pyyaml                    3.13             py36hfa6e2cd_0
pyzmq                     17.1.2           py36hfa6e2cd_0
qt                        5.9.5            vc14he4a7d60_0  [vc14]
qtawesome                 0.4.4            py36h5aa48f6_0
qtconsole                 4.4.1                    py36_0
qtpy                      1.5.0                    py36_0
requests                  2.19.1                   py36_0
rope                      0.11.0                   py36_0
ruamel_yaml               0.15.46          py36hfa6e2cd_0
scikit-image              0.14.0           py36h6538335_1
scikit-learn              0.19.1           py36h53aea1b_0
scipy                     1.1.0            py36h672f292_0
seaborn                   0.9.0                    py36_0
send2trash                1.5.0                    py36_0
service_identity          17.0.0           py36h28b3542_0
setuptools                40.2.0                   py36_0
setuptools                40.4.3                    <pip>
simplegeneric             0.8.1                    py36_2
singledispatch            3.4.0.3          py36h17d0c80_0
sip                       4.19.8           py36h6538335_0
six                       1.11.0                   py36_1
snappy                    1.1.7                h777316e_3
snowballstemmer           1.2.1            py36h763602f_0
sortedcollections         1.0.1                    py36_0
sortedcontainers          2.0.5                    py36_0
sphinx                    1.7.9                    py36_0
sphinxcontrib             1.0                      py36_1
sphinxcontrib-websupport  1.1.0                    py36_1
spyder                    3.3.1                    py36_1
spyder-kernels            0.2.6                    py36_0
sqlalchemy                1.2.11           py36hfa6e2cd_0
sqlite                    3.23.1               h35aae40_0
statsmodels               0.9.0            py36h452e1ab_0
sympy                     1.2                      py36_0
tblib                     1.3.2            py36h30f5020_0
tensorboard               1.9.0            py36he025d50_0
tensorflow                1.9.0           gpu_py36hfdee9c2_1
tensorflow-base           1.9.0           gpu_py36h6e53903_0
tensorflow-gpu            1.9.0                hf154084_0    anaconda
termcolor                 1.1.0                    py36_1
terminado                 0.8.1                    py36_1
testpath                  0.3.1            py36h2698cfe_0
tk                        8.6.7                hcb92d03_3
toolz                     0.9.0                    py36_0
tornado                   5.1              py36hfa6e2cd_0
tqdm                      4.26.0           py36h28b3542_0
traitlets                 4.3.2            py36h096827d_0
twisted                   18.7.0           py36hfa6e2cd_1
typed-ast                 1.1.0            py36hfa6e2cd_0
typing                    3.6.4                    py36_0
unicodecsv                0.14.1           py36h6450c06_0
urllib3                   1.23                     py36_0
vc                        14.1                 h21ff451_3    anaconda
vs2015_runtime            15.5.2                        3    anaconda
wcwidth                   0.1.7            py36h3d5aa90_0
webencodings              0.5.1                    py36_1
werkzeug                  0.14.1                   py36_0
wheel                     0.31.1                   py36_0
widgetsnbextension        3.4.1                    py36_0
win_inet_pton             1.0.1                    py36_1
win_unicode_console       0.5              py36hcdbd4b5_0
wincertstore              0.2              py36h7fe50ca_0
winpty                    0.4.3                         4
wrapt                     1.10.11          py36hfa6e2cd_2
xlrd                      1.1.0                    py36_1
xlsxwriter                1.1.0                    py36_0
xlwings                   0.11.8                   py36_0
xlwt                      1.3.0            py36h1a4751e_0
yaml                      0.1.7                hc54c509_2
zeromq                    4.2.5                hc6251cf_0
zict                      0.1.3                    py36_0
zlib                      1.2.11               h8395fce_2
zope                      1.0                      py36_1
zope.interface            4.5.0            py36hfa6e2cd_0

(base) C:\WINDOWS\system32>conda install -c hanslovsky imglib2-imglyb
Solving environment: done

## Package Plan ##

  environment location: C:\ProgramData\Anaconda3

  added / updated specs:
    - imglib2-imglyb


The following NEW packages will be INSTALLED:

    imglib2-imglyb: 0.0.0.post135-py36_0 hanslovsky

Proceed ([y]/n)? y

Preparing transaction: done
Verifying transaction: done
Executing transaction: done

(base) C:\WINDOWS\system32>SET PYJNIUS_JAR=C:\ProgramData\Anaconda3\pkgs\pyjnius-1.1.1.post54-py36h6538335_0\share\pyjnius\pyjnius.jar

(base) C:\WINDOWS\system32>SET PYJNIUS_JAR_BACKUP=''

(base) C:\WINDOWS\system32>SET JDK_HOME=C:\Program Files\Java\jdk1.8.0_181\

(base) C:\WINDOWS\system32>SET JDK_HOME_BACKUP=''

(base) C:\WINDOWS\system32>SET PATH=C:\ProgramData\Anaconda3\Library\jre\bin\server;C:\ProgramData\Anaconda3\Library\bin;C:\ProgramData\Anaconda3;C:\ProgramData\Anaconda3\Library\mingw-w64\bin;C:\ProgramData\Anaconda3\Library\usr\bin;C:\ProgramData\Anaconda3\Library\bin;C:\ProgramData\Anaconda3\Scripts;C:\ProgramData\Anaconda3\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.2\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.2\libnvvp;C:\ProgramData\Anaconda3;C:\ProgramData\Anaconda3\Library\mingw-w64\bin;C:\ProgramData\Anaconda3\Library\usr\bin;C:\ProgramData\Anaconda3\Library\bin;C:\ProgramData\Anaconda3\Scripts;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\dotnet\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Git\cmd;C:\Program Files\PuTTY\;C:\Program Files\WIDCOMM\Bluetooth Software\;C:\Program Files\WIDCOMM\Bluetooth Software\syswow64;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Java\jdk1.8.0_181\bin`;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Users\Bojing\AppData\Local\Microsoft\WindowsApps;C:\Users\Bojing\AppData\Local\GitHubDesktop\bin;C:\Users\Bojing\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Java\jdk1.8.0_181\jre\bin\server\"

(base) C:\WINDOWS\system32>SET PATH_BACKUP=''

(base) C:\WINDOWS\system32>set "JAVA_HOME="

(base) C:\WINDOWS\system32>SET "IMGLYB_JAR=''"

(base) C:\WINDOWS\system32>SET "IMGLYB_JAR_BACKUP=''"

(base) C:\WINDOWS\system32>SET "IMGLYB_JAR_BACKUP=''"

(base) C:\WINDOWS\system32>SET "IMGLYB_JAR=C:\ProgramData\Anaconda3\share\imglyb\imglib2-imglyb-0.1.0-SNAPSHOT.jar"

(base) C:\WINDOWS\system32>set "JAVA_HOME_CONDA_BACKUP="

(base) C:\WINDOWS\system32>set "JAVA_HOME=C:\ProgramData\Anaconda3\Library"

(base) C:\WINDOWS\system32>SET "PYJNIUS_JAR_BACKUP=C:\ProgramData\Anaconda3\pkgs\pyjnius-1.1.1.post54-py36h6538335_0\share\pyjnius\pyjnius.jar"

(base) C:\WINDOWS\system32>SET "PYJNIUS_JAR=C:\ProgramData\Anaconda3\share\pyjnius\pyjnius.jar"

(base) C:\WINDOWS\system32>SET "JDK_HOME_BACKUP=C:\Program Files\Java\jdk1.8.0_181\"

(base) C:\WINDOWS\system32>SET "JDK_HOME=C:\ProgramData\Anaconda3\Library"

(base) C:\WINDOWS\system32>SET "PATH_BACKUP=C:\ProgramData\Anaconda3\Library\jre\bin\server;C:\ProgramData\Anaconda3\Library\bin;C:\ProgramData\Anaconda3\Library\jre\bin\server;C:\ProgramData\Anaconda3\Library\bin;C:\ProgramData\Anaconda3;C:\ProgramData\Anaconda3\Library\mingw-w64\bin;C:\ProgramData\Anaconda3\Library\usr\bin;C:\ProgramData\Anaconda3\Library\bin;C:\ProgramData\Anaconda3\Scripts;C:\ProgramData\Anaconda3\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.2\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.2\libnvvp;C:\ProgramData\Anaconda3;C:\ProgramData\Anaconda3\Library\mingw-w64\bin;C:\ProgramData\Anaconda3\Library\usr\bin;C:\ProgramData\Anaconda3\Library\bin;C:\ProgramData\Anaconda3\Scripts;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\dotnet\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Git\cmd;C:\Program Files\PuTTY\;C:\Program Files\WIDCOMM\Bluetooth Software\;C:\Program Files\WIDCOMM\Bluetooth Software\syswow64;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Java\jdk1.8.0_181\bin`;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Users\Bojing\AppData\Local\Microsoft\WindowsApps;C:\Users\Bojing\AppData\Local\GitHubDesktop\bin;C:\Users\Bojing\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Java\jdk1.8.0_181\jre\bin\server\"

#37

Hi @ctrueden,

Sure, I would be happy to - only that I admit I don’t actually work on image processing full-time, and my responses maybe periodic (whenever I find myself outside of the clinic). If you are OK with this, let me know how I can help


#38

Please try to run this line from the windows command line in the appropriate conda environment instead of running it in spyder:

python -c "import imglyb; print(imglyb)"

I am not familiar with spyder and I am worried that it does not inherit environment variables properly (on Windows). I had a similar issue with PyCharm: I was able to activate different conda environments but only the python interpreter would be used; environment variables would not be updated at all.

Regardless of the bug, I noticed that you ran

conda install -c hanslovsky imglib2-imglyb

Instead, please run

conda install -c hanslovsky imglyb

The python and java parts of imglyb were split into two separate packages for better source management.


#39

Thanks, and sorry for my delayed response. If these IDEs don’t inherit environment variables, what do you recommend?


#40

I tested the imagej.py module with the latest version of imglyb as follows:

conda create -n imagej python=3.6
source activate imagej
pip install imagej
conda install -c hanslovsky imglib2-imglyb
python -c "import imagej
imagej.init('/Applications/Fiji.app')"

And the output I got was:

Added 368 JARs to the Java classpath.
[WARNING] 4 exceptions occurred during plugin discovery.

So it still seems to work, at least on macOS. I have not tried it on Windows, and I’m sorry to say I do not have time to investigate that right now. It may be that the automagical discovery of Java and ImgLyb does not work at all on Windows, since IIRC we never tested that.

ValueError: VM is already running, can't set options

If I had to guess, perhaps you already did import imglyb or some other similar invocation? You should not import imglyb explicitly when using imagej.py. The import imagej and imagej.init commands take care of everything for you, including setting the necessary environment variables. The very first things you should do are import imagej followed by imagej.init(...).

Please file an issue on https://github.com/imagej/imagej.py/issues documenting the problem with Windows, so that we can investigate later as time allows.