Maven path setup in pyimagej

maven
imagej
jupyter
pyimagej

#1

HI while trying to import imagej into python and getting a Fiji instance to open from there I ran into maven path issues. In brief, the error is

‘ExecutableNotFound: mvn not found on path /Users/aimachine/anaconda3/bin’

I check the path of maven by running

mvn --version

and it shows:

Maven home: /Users/aimachine/anaconda3/envs/imagej/opt/maven

Java version: 1.8.0_192, vendor: Azul Systems, Inc.,runtime:/Users/aimachine/anaconda3/envs/imagej/jre

The error comes from imglyb.
It is looking for maven in a different directory, how do I specify my mvn home for imglyb so that it can find mvn? I am running this from jupyter notebook.

@ctrueden @hanslovsky


#2

@kapoorlab Based on your paths, I assume you are using conda. Did you install pyimagej via conda install pyimagej? Did you launch Jupyter notebook via jupyter notebook from the active imagej environment? You should not have to specify any paths or environment variables manually.


#3

I think more details would be helpful:

  • What is the exact code you are calling and
  • where are you calling it from (cmd line?)
  • Do you have a minmal working exapmle to demonstrate the error?
  • Paste the entire error message
  • What does the environment look like from inside your python interpreter?

#4

@ctrueden @hanslovsky

Yes I installed this via conda and the exact steps I took are detailed below:

Ok this is what I did:

conda env create -f environment.yml
source activate imagej
conda install notebook ipykernel
ipython kernel install --user
pip install scyjava
pip install jnius
source deactivate
jupyter notebook

Now select the kernel imagej (in Jupyter notebook) and import imagej statement would work

After Selecting the kernel as imagej from jupyter notebook I tried only two statements

import imagej (worked) and second

ij = imagej.init('/Applications/Fiji.app')

The notebook is here:

The error message I got there was:

[Added 432 JARs to the Java classpath.
---------------------------------------------------------------------------
ExecutableNotFound                        Traceback (most recent call last)
<ipython-input-2-a5d82c8e416f> in <module>
----> 1 ij = imagej.init('/Applications/Fiji.app')

~/pyimagej/imagej/imagej.py in init(ij_dir_or_version_or_endpoint, headless)
    102 
    103     # Must import imglyb (not scyjava) to spin up the JVM now.
--> 104     import imglyb
    105     from jnius import autoclass
    106 

~/anaconda3/envs/imagej/lib/python3.6/site-packages/imglyb/__init__.py in <module>
     73 
     74 
---> 75 config = _init_jvm_options()
     76 
     77 if sys.version_info[0] < 3:

~/anaconda3/envs/imagej/lib/python3.6/site-packages/imglyb/__init__.py in _init_jvm_options()
     61         m2_repo=LOCAL_MAVEN_REPO,
     62         repositories=imglyb_config.get_repositories(),
---> 63         verbose=2
     64     )
     65     jnius_config.add_classpath(os.path.join(workspace, '*'))

~/anaconda3/envs/imagej/lib/python3.6/site-packages/jrun/jrun.py in resolve_dependencies(endpoint_string, cache_dir, m2_repo, update_cache, force_update, manage_dependencies, repositories, shortcuts, verbose)
    409 
    410     try:
--> 411         mvn     = executable_path_or_raise('mvn')
    412         mvn_out = run_and_combine_outputs(mvn, *mvn_args)
    413     except subprocess.CalledProcessError as e:

~/anaconda3/envs/imagej/lib/python3.6/site-packages/jrun/jrun.py in executable_path_or_raise(tool)
    141     path = executable_path(tool)
    142     if path is None:
--> 143         raise ExecutableNotFound(tool, os.getenv('PATH'))
    144     return path
    145 

ExecutableNotFound: mvn not found on path /Users/aimachine/anaconda3/bin:/Users/aimachine/anaconda3/condabin:/Users/aimachine/.rvm/gems/ruby-2.5.1/bin:/Users/aimachine/.rvm/gems/ruby-2.5.1@global/bin:/Users/aimachine/.rvm/rubies/ruby-2.5.1/bin:/Users/aimachine/anaconda3/bin:/Users/aimachine/anaconda3/bin:/Users/aimachine/anaconda2/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin:/Users/aimachine/.rvm/bin]

#5

Don’t deactivate your conda environment before running jupyter. The whole purpose of the conda env is to provide all the correct executables and known paths.


#6

@imagejan Yeah, I was doing that because I thought that selecting the kernel from inside the jupyter notebook would have the same effect. But now I do not deactivate it and selcet the kernel as python3. There could be advantages to this as I can also select the kernel as tensorflow and then run multiple application in the same notebook.

Just one more thing, imagej.init statement takes way toooo long to finish. I ran the notebook immediately after your reply and it has still not finished the execution of imagej.init. Using a MacPro, does it take that long for you also?

Cheers


#7

And now a new error, still maven related:

Added 432 JARs to the Java classpath.
INFO 2019-02-01 13:37:10,938: Failed to bootstrap the artifact.
INFO 2019-02-01 13:37:10,939: 
INFO 2019-02-01 13:37:10,940: Possible solutions:
INFO 2019-02-01 13:37:10,940: * Double check the endpoint for correctness (https://search.maven.org/).
INFO 2019-02-01 13:37:10,941: * Add needed repositories to ~/.jrunrc [repositories] block (see README).
INFO 2019-02-01 13:37:10,941: * Try with an explicit version number (release metadata might be wrong).

---------------------------------------------------------------------------
CalledProcessError                        Traceback (most recent call last)
<ipython-input-2-a5d82c8e416f> in <module>
----> 1 ij = imagej.init('/Applications/Fiji.app')

~/pyimagej/imagej/imagej.py in init(ij_dir_or_version_or_endpoint, headless)
    102 
    103     # Must import imglyb (not scyjava) to spin up the JVM now.
--> 104     import imglyb
    105     from jnius import autoclass
    106 

~/anaconda3/envs/imagej/lib/python3.6/site-packages/imglyb/__init__.py in <module>
     73 
     74 
---> 75 config = _init_jvm_options()
     76 
     77 if sys.version_info[0] < 3:

~/anaconda3/envs/imagej/lib/python3.6/site-packages/imglyb/__init__.py in _init_jvm_options()
     61         m2_repo=LOCAL_MAVEN_REPO,
     62         repositories=imglyb_config.get_repositories(),
---> 63         verbose=2
     64     )
     65     jnius_config.add_classpath(os.path.join(workspace, '*'))

~/anaconda3/envs/imagej/lib/python3.6/site-packages/jrun/jrun.py in resolve_dependencies(endpoint_string, cache_dir, m2_repo, update_cache, force_update, manage_dependencies, repositories, shortcuts, verbose)
    419         _logger.info("* Try with an explicit version number (release metadata might be wrong).")
    420         print()
--> 421         raise e
    422 
    423 

~/anaconda3/envs/imagej/lib/python3.6/site-packages/jrun/jrun.py in resolve_dependencies(endpoint_string, cache_dir, m2_repo, update_cache, force_update, manage_dependencies, repositories, shortcuts, verbose)
    410     try:
    411         mvn     = executable_path_or_raise('mvn')
--> 412         mvn_out = run_and_combine_outputs(mvn, *mvn_args)
    413     except subprocess.CalledProcessError as e:
    414         _logger.info("Failed to bootstrap the artifact.")

~/anaconda3/envs/imagej/lib/python3.6/site-packages/jrun/jrun.py in run_and_combine_outputs(command, *args)
    183 
    184 def run_and_combine_outputs(command, *args):
--> 185     return subprocess.check_output((command,) + args, stderr=subprocess.STDOUT)
    186 
    187 

~/anaconda3/envs/imagej/lib/python3.6/subprocess.py in check_output(timeout, *popenargs, **kwargs)
    354 
    355     return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
--> 356                **kwargs).stdout
    357 
    358 

~/anaconda3/envs/imagej/lib/python3.6/subprocess.py in run(input, timeout, check, *popenargs, **kwargs)
    436         if check and retcode:
    437             raise CalledProcessError(retcode, process.args,
--> 438                                      output=stdout, stderr=stderr)
    439     return CompletedProcess(process.args, retcode, stdout, stderr)
    440 

CalledProcessError: Command '('/Users/aimachine/anaconda3/envs/imagej/bin/mvn', '-B', '-f', '/Users/aimachine/.imglyb-jars/net/imglib/imglib2-imglyb/0.3.0/pom.xml', 'dependency:resolve', '-X')' returned non-zero exit status 1.



#8

Also, pyjnius and scyjava are dependencies already defined in the environment.yml. There should be no need to install via pip, maybe this installation somehow introduced a version skew?


#9

Does not seem like that, I did pip uninstall scyjava and pip uninstall jnius and removed the imagej enviornment from envs folder and ran conda create enviornment statement and it made the things even worse. Now I get error at import imagej block

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-35574f180618> in <module>()
----> 1 import imagej

~/pyimagej/imagej/__init__.py in <module>()
----> 1 from .imagej import *
      2 

~/pyimagej/imagej/imagej.py in <module>()
     10 
     11 import os
---> 12 import scyjava_config
     13 from pathlib import Path
     14 import numpy

ModuleNotFoundError: No module named 'scyjava_config'

If I locate scyjava package files it shows me this output:

u934-bdd-0-52-6887:imagej aimachine$ locate scyjava
/Users/aimachine/anaconda3/envs/imagej/conda-meta/scyjava-0.1.0-py37_1001.json
/Users/aimachine/anaconda3/envs/imagej/lib/python3.7/site-packages/__pycache__/scyjava_config.cpython-37.pyc
/Users/aimachine/anaconda3/envs/imagej/lib/python3.7/site-packages/scyjava
/Users/aimachine/anaconda3/envs/imagej/lib/python3.7/site-packages/scyjava/__init__.py
/Users/aimachine/anaconda3/envs/imagej/lib/python3.7/site-packages/scyjava/__pycache__
/Users/aimachine/anaconda3/envs/imagej/lib/python3.7/site-packages/scyjava/__pycache__/__init__.cpython-37.pyc
/Users/aimachine/anaconda3/envs/imagej/lib/python3.7/site-packages/scyjava/__pycache__/convert.cpython-37.pyc
/Users/aimachine/anaconda3/envs/imagej/lib/python3.7/site-packages/scyjava/convert.py
/Users/aimachine/anaconda3/envs/imagej/lib/python3.7/site-packages/scyjava-0.1.0.dist-info
/Users/aimachine/anaconda3/envs/imagej/lib/python3.7/site-packages/scyjava-0.1.0.dist-info/INSTALLER
/Users/aimachine/anaconda3/envs/imagej/lib/python3.7/site-packages/scyjava-0.1.0.dist-info/METADATA
/Users/aimachine/anaconda3/envs/imagej/lib/python3.7/site-packages/scyjava-0.1.0.dist-info/RECORD
/Users/aimachine/anaconda3/envs/imagej/lib/python3.7/site-packages/scyjava-0.1.0.dist-info/WHEEL
/Users/aimachine/anaconda3/envs/imagej/lib/python3.7/site-packages/scyjava-0.1.0.dist-info/top_level.txt
/Users/aimachine/anaconda3/envs/imagej/lib/python3.7/site-packages/scyjava_config.py
/Users/aimachine/anaconda3/pkgs/scyjava-0.1.0-py37_1001
/Users/aimachine/anaconda3/pkgs/scyjava-0.1.0-py37_1001/info
/Users/aimachine/anaconda3/pkgs/scyjava-0.1.0-py37_1001/info/about.json
/Users/aimachine/anaconda3/pkgs/scyjava-0.1.0-py37_1001/info/files
/Users/aimachine/anaconda3/pkgs/scyjava-0.1.0-py37_1001/info/git
/Users/aimachine/anaconda3/pkgs/scyjava-0.1.0-py37_1001/info/hash_input.json
/Users/aimachine/anaconda3/pkgs/scyjava-0.1.0-py37_1001/info/index.json
/Users/aimachine/anaconda3/pkgs/scyjava-0.1.0-py37_1001/info/paths.json
/Users/aimachine/anaconda3/pkgs/scyjava-0.1.0-py37_1001/info/recipe
/Users/aimachine/anaconda3/pkgs/scyjava-0.1.0-py37_1001/info/recipe/conda_build_config.yaml
/Users/aimachine/anaconda3/pkgs/scyjava-0.1.0-py37_1001/info/recipe/meta.yaml
/Users/aimachine/anaconda3/pkgs/scyjava-0.1.0-py37_1001/info/recipe/meta.yaml.template
/Users/aimachine/anaconda3/pkgs/scyjava-0.1.0-py37_1001/info/repodata_record.json
/Users/aimachine/anaconda3/pkgs/scyjava-0.1.0-py37_1001/info/test
/Users/aimachine/anaconda3/pkgs/scyjava-0.1.0-py37_1001/info/test/run_test.py
/Users/aimachine/anaconda3/pkgs/scyjava-0.1.0-py37_1001/lib
/Users/aimachine/anaconda3/pkgs/scyjava-0.1.0-py37_1001/lib/python3.7
/Users/aimachine/anaconda3/pkgs/scyjava-0.1.0-py37_1001/lib/python3.7/site-packages
/Users/aimachine/anaconda3/pkgs/scyjava-0.1.0-py37_1001/lib/python3.7/site-packages/__pycache__
/Users/aimachine/anaconda3/pkgs/scyjava-0.1.0-py37_1001/lib/python3.7/site-packages/__pycache__/scyjava_config.cpython-37.pyc
/Users/aimachine/anaconda3/pkgs/scyjava-0.1.0-py37_1001/lib/python3.7/site-packages/scyjava
/Users/aimachine/anaconda3/pkgs/scyjava-0.1.0-py37_1001/lib/python3.7/site-packages/scyjava/__init__.py
/Users/aimachine/anaconda3/pkgs/scyjava-0.1.0-py37_1001/lib/python3.7/site-packages/scyjava/__pycache__
/Users/aimachine/anaconda3/pkgs/scyjava-0.1.0-py37_1001/lib/python3.7/site-packages/scyjava/__pycache__/__init__.cpython-37.pyc
/Users/aimachine/anaconda3/pkgs/scyjava-0.1.0-py37_1001/lib/python3.7/site-packages/scyjava/__pycache__/convert.cpython-37.pyc
/Users/aimachine/anaconda3/pkgs/scyjava-0.1.0-py37_1001/lib/python3.7/site-packages/scyjava/convert.py
/Users/aimachine/anaconda3/pkgs/scyjava-0.1.0-py37_1001/lib/python3.7/site-packages/scyjava-0.1.0.dist-info
/Users/aimachine/anaconda3/pkgs/scyjava-0.1.0-py37_1001/lib/python3.7/site-packages/scyjava-0.1.0.dist-info/INSTALLER
/Users/aimachine/anaconda3/pkgs/scyjava-0.1.0-py37_1001/lib/python3.7/site-packages/scyjava-0.1.0.dist-info/METADATA
/Users/aimachine/anaconda3/pkgs/scyjava-0.1.0-py37_1001/lib/python3.7/site-packages/scyjava-0.1.0.dist-info/RECORD
/Users/aimachine/anaconda3/pkgs/scyjava-0.1.0-py37_1001/lib/python3.7/site-packages/scyjava-0.1.0.dist-info/WHEEL
/Users/aimachine/anaconda3/pkgs/scyjava-0.1.0-py37_1001/lib/python3.7/site-packages/scyjava-0.1.0.dist-info/top_level.txt
/Users/aimachine/anaconda3/pkgs/scyjava-0.1.0-py37_1001/lib/python3.7/site-packages/scyjava_config.py
/Users/aimachine/anaconda3/pkgs/scyjava-0.1.0-py37_1001.tar.bz2

It seems anaconda3 pkgs has a scyjava and imagej/lib has a different scyjava, do you this is why my import imagej is not working?

Cheers,


#10

Unfortunately, I cannot reproduce the bug on my machine (which is Linux machine, though). This runs successfully on my machine:

$ python -c 'import imagej; ij = imagej.init("/home/hanslovskyp/local/Fiji.app"); print(ij)' 
Added 370 JARs to the Java classpath.
<net.imagej.ImageJ at 0x7f8bd6e41a40 jclass=net/imagej/ImageJ jself=<LocalRef obj=0x560755227730 at 0x7f8bd6ecbe50>>

I did:

git clone git@github.com:imagej/pyimagej
cd pyimagej
conda env create -f environment.yml
conda activate imagej
python -c 'import imagej; ij = imagej.init("/home/hanslovskyp/local/Fiji.app"); print(ij)'

This is a list of packages inside my imagej environment:

$ conda list
# packages in environment at /home/hanslovskyp/miniconda3/envs/imagej:
#
# Name                    Version                   Build  Channel
asn1crypto                0.24.0                py37_1003    conda-forge
atk                       2.25.90           hb9dd440_1002    conda-forge
blas                      1.1                    openblas    conda-forge
bzip2                     1.0.6             h14c3975_1002    conda-forge
ca-certificates           2018.11.29           ha4d7672_0    conda-forge
cairo                     1.16.0            ha4e643d_1000    conda-forge
certifi                   2018.11.29            py37_1000    conda-forge
cffi                      1.11.5          py37h9745a5d_1001    conda-forge
chardet                   3.0.4                 py37_1003    conda-forge
cryptography              2.5              py37hb7f436b_0    conda-forge
cycler                    0.10.0                     py_1    conda-forge
dbus                      1.13.0            h4e0c4b3_1000    conda-forge
expat                     2.2.5             hf484d3e_1002    conda-forge
fontconfig                2.13.1            h2176d3f_1000    conda-forge
freetype                  2.9.1             h94bbf69_1005    conda-forge
gdk-pixbuf                2.36.12           h49783d7_1002    conda-forge
gettext                   0.19.8.1          h9745a5d_1001    conda-forge
glib                      2.58.2            hf63aee3_1001    conda-forge
gobject-introspection     1.58.2          py37h2da5eee_1000    conda-forge
graphite2                 1.3.13            hf484d3e_1000    conda-forge
gstreamer                 1.14.4            h66beb1c_1001    conda-forge
gtk2                      2.24.31           hb68c50a_1001    conda-forge
harfbuzz                  2.3.0             h6824563_1001    conda-forge
icu                       58.2              hf484d3e_1000    conda-forge
idna                      2.8                   py37_1000    conda-forge
imglyb                    0.3.4           py37h24bf2e0_1000    conda-forge
jgo                       0.3.0                 py37_1000    conda-forge
jpeg                      9c                h14c3975_1001    conda-forge
kiwisolver                1.0.1           py37h6bb024c_1002    conda-forge
libffi                    3.2.1             hf484d3e_1005    conda-forge
libgcc-ng                 7.3.0                hdf63c60_0    conda-forge
libgfortran-ng            7.2.0                hdf63c60_3    conda-forge
libiconv                  1.15              h14c3975_1004    conda-forge
libpng                    1.6.36            h84994c4_1000    conda-forge
libstdcxx-ng              7.3.0                hdf63c60_0    conda-forge
libtiff                   4.0.10            h648cc4a_1001    conda-forge
libuuid                   2.32.1            h14c3975_1000    conda-forge
libxcb                    1.13              h14c3975_1002    conda-forge
libxml2                   2.9.8             h143f9aa_1005    conda-forge
matplotlib                3.0.2                 py37_1002    conda-forge
matplotlib-base           3.0.2           py37h167e16e_1002    conda-forge
maven                     3.6.0                         0    conda-forge
ncurses                   6.1               hf484d3e_1002    conda-forge
numpy                     1.16.1          py37_blas_openblash1522bff_0  [blas_openblas]  conda-forge
olefile                   0.46                       py_0    conda-forge
openblas                  0.3.3             h9ac9557_1001    conda-forge
openjdk                   8.0.192           h14c3975_1003    conda-forge
openssl                   1.0.2p            h14c3975_1002    conda-forge
pango                     1.40.14           h4ea9474_1004    conda-forge
pcre                      8.41              hf484d3e_1003    conda-forge
pillow                    5.4.1           py37h00a061d_1000    conda-forge
pip                       19.0.1                   py37_0    conda-forge
pixman                    0.34.0            h14c3975_1003    conda-forge
pthread-stubs             0.4               h14c3975_1001    conda-forge
pycparser                 2.19                       py_0    conda-forge
pyjnius                   1.1.4           py37h93af967_1004    conda-forge
pyopenssl                 18.0.0                py37_1000    conda-forge
pyparsing                 2.3.1                      py_0    conda-forge
pyqt                      5.6.0           py37h13b7fb3_1008    conda-forge
pysocks                   1.6.8                 py37_1002    conda-forge
python                    3.7.1             hd21baee_1000    conda-forge
python-dateutil           2.7.5                      py_0    conda-forge
qt                        5.6.2             hce4f676_1013    conda-forge
readline                  7.0               hf8c457e_1001    conda-forge
requests                  2.21.0                py37_1000    conda-forge
scyjava                   0.1.0                 py37_1001    conda-forge
setuptools                40.7.1                   py37_0    conda-forge
sip                       4.18.1          py37hf484d3e_1000    conda-forge
six                       1.12.0                py37_1000    conda-forge
sqlite                    3.26.0            h67949de_1000    conda-forge
tk                        8.6.9             h84994c4_1000    conda-forge
tornado                   5.1.1           py37h14c3975_1000    conda-forge
urllib3                   1.24.1                py37_1000    conda-forge
wheel                     0.32.3                   py37_0    conda-forge
xorg-kbproto              1.0.7             h14c3975_1002    conda-forge
xorg-libice               1.0.9             h14c3975_1004    conda-forge
xorg-libsm                1.2.3             h4937e3b_1000    conda-forge
xorg-libx11               1.6.6             h14c3975_1000    conda-forge
xorg-libxau               1.0.8             h14c3975_1006    conda-forge
xorg-libxdmcp             1.1.2             h14c3975_1007    conda-forge
xorg-libxext              1.3.3             h14c3975_1004    conda-forge
xorg-libxrender           0.9.10            h14c3975_1002    conda-forge
xorg-libxt                1.1.5             h14c3975_1002    conda-forge
xorg-renderproto          0.11.1            h14c3975_1002    conda-forge
xorg-xextproto            7.3.0             h14c3975_1002    conda-forge
xorg-xproto               7.0.31            h14c3975_1007    conda-forge
xz                        5.2.4             h14c3975_1001    conda-forge
zlib                      1.2.11            h14c3975_1004    conda-forge

#11

@hanslovsky I see,

well in your miniconda3/pkgs do you have scyjava also present or is it only present in miniconda3/envs/imagej?


#12
$ ls -1 ~/miniconda3/pkgs/scyjava* -d
/home/hanslovskyp/miniconda3/pkgs/scyjava-0.1.0-py37_1001
/home/hanslovskyp/miniconda3/pkgs/scyjava-0.1.0-py37_1001.tar.bz2

#13

@hanslovsky Yeah, thats the same as mine. I will try to remove all pyimagej and start from scratch with the installation instructions that you tried on your linux machine and see if that works for me as well and then report it back.

Thanks


#14

~/miniconda3/pkgs is just a folder Anaconda uses to cache packages it downloads so it’s normal to see scyjava there.

As for all the IJ Python related packages I wouldn’t install them using pip but conda only since the conda packages have some init scripts that needs to be run at the end of the installation in order to setup everything correctly.

Last thing about the Jupyter notebook server. You can fire the notebook from the env you want to use:

conda activate imagej
jupyter lab

But you can also install the package called nb_conda_kernels into your root/base env:

conda activate base
conda install nb_conda_kernels

and then fire Jupyter from your root/base env. Then you should be able to choose for each notebook the kernel you want to use being base, imagej or whatever kernel you have in your Conda envs. An example in Jupyter Lab:

Screenshot%20from%202019-02-01%2014-16-59


#15

@hanslovsky After removing the previous installation and running your instructions till conda list gives me a little different output, some packages that you have in your list are not present on mine, example:
atk ,dbus, expat, fontconfig… Which is strage coz I forked the pyimagej repo from github page of curtis and then cloned the repo on my Mac and ran your instructions.

# packages in environment at /Users/aimachine/anaconda3/envs/imagej:
#
# Name                    Version                   Build  Channel
asn1crypto                0.24.0                py37_1003    conda-forge
blas                      1.1                    openblas    conda-forge
bzip2                     1.0.6             h1de35cc_1002    conda-forge
ca-certificates           2018.11.29           ha4d7672_0    conda-forge
certifi                   2018.11.29            py37_1000    conda-forge
cffi                      1.11.5          py37h342bebf_1001    conda-forge
chardet                   3.0.4                 py37_1003    conda-forge
cryptography              2.5              py37hdbc3d79_0    conda-forge
cycler                    0.10.0                     py_1    conda-forge
freetype                  2.9.1             h597ad8a_1005    conda-forge
idna                      2.8                   py37_1000    conda-forge
imglyb                    0.3.4           py37h24bf2e0_1000    conda-forge
jgo                       0.3.0                 py37_1000    conda-forge
jpeg                      9c                h1de35cc_1001    conda-forge
kiwisolver                1.0.1           py37h04f5b5a_1002    conda-forge
libcxx                    7.0.0                h2d50403_2    conda-forge
libffi                    3.2.1             h0a44026_1005    conda-forge
libgfortran               3.0.1                h93005f0_2
libpng                    1.6.36            ha441bb4_1000    conda-forge
libtiff                   4.0.10            h79f4b77_1001    conda-forge
llvm-meta                 7.0.0                         0    conda-forge
matplotlib                3.0.2                 py37_1002    conda-forge
matplotlib-base           3.0.2           py37hf043ca5_1002    conda-forge
maven                     3.6.0                         0    conda-forge
ncurses                   6.1               h0a44026_1002    conda-forge
numpy                     1.16.1          py37_blas_openblash486cb9f_0  [blas_openblas]  conda-forge
olefile                   0.46                       py_0    conda-forge
openblas                  0.3.3             hdc02c5d_1001    conda-forge
openjdk                   8.0.192           h1de35cc_1003    conda-forge
openssl                   1.0.2p            h1de35cc_1002    conda-forge
pillow                    5.4.1           py37hbddbef0_1000    conda-forge
pip                       19.0.1                   py37_0    conda-forge
pycparser                 2.19                       py_0    conda-forge
pyjnius                   1.1.4           py37h90b5fae_1004    conda-forge
pyopenssl                 18.0.0                py37_1000    conda-forge
pyparsing                 2.3.1                      py_0    conda-forge
pysocks                   1.6.8                 py37_1002    conda-forge
python                    3.7.1             h145921a_1000    conda-forge
python-dateutil           2.7.5                      py_0    conda-forge
readline                  7.0               hcfe32e1_1001    conda-forge
requests                  2.21.0                py37_1000    conda-forge
scyjava                   0.1.0                 py37_1001    conda-forge
setuptools                40.7.1                   py37_0    conda-forge
six                       1.12.0                py37_1000    conda-forge
sqlite                    3.26.0            h1765d9f_1000    conda-forge
tk                        8.6.9             ha441bb4_1000    conda-forge
tornado                   5.1.1           py37h1de35cc_1000    conda-forge
urllib3                   1.24.1                py37_1000    conda-forge
wheel                     0.32.3                   py37_0    conda-forge
xz                        5.2.4             h1de35cc_1001    conda-forge
zlib                      1.2.11            h1de35cc_1004    conda-forge

The import imagej statement works but I am back to the error I saw before:

INFO 2019-02-01 20:24:11,538: Failed to bootstrap the artifact.
INFO 2019-02-01 20:24:11,538:
INFO 2019-02-01 20:24:11,538: Possible solutions:
INFO 2019-02-01 20:24:11,538: * Double check the endpoint for correctness (https://search.maven.org/).
INFO 2019-02-01 20:24:11,538: * Add needed repositories to ~/.jgorc [repositories] block (see README).
INFO 2019-02-01 20:24:11,538: * Try with an explicit version number (release metadata might be wrong).

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/aimachine/pyimagej/imagej/imagej.py", line 104, in init
    import imglyb
  File "/Users/aimachine/anaconda3/envs/imagej/lib/python3.7/site-packages/imglyb/__init__.py", line 41, in <module>
    config, _ = _init_jvm_options()
  File "/Users/aimachine/anaconda3/envs/imagej/lib/python3.7/site-packages/imglyb/__init__.py", line 36, in _init_jvm_options
    import scyjava
  File "/Users/aimachine/anaconda3/envs/imagej/lib/python3.7/site-packages/scyjava/__init__.py", line 55, in <module>
    jnius = _init_jvm()
  File "/Users/aimachine/anaconda3/envs/imagej/lib/python3.7/site-packages/scyjava/__init__.py", line 41, in _init_jvm
    verbose=scyjava_config.get_verbose()
  File "/Users/aimachine/anaconda3/envs/imagej/lib/python3.7/site-packages/jgo/jgo.py", line 457, in resolve_dependencies
    raise e
  File "/Users/aimachine/anaconda3/envs/imagej/lib/python3.7/site-packages/jgo/jgo.py", line 448, in resolve_dependencies
    mvn_out = run_and_combine_outputs(mvn, *mvn_args)
  File "/Users/aimachine/anaconda3/envs/imagej/lib/python3.7/site-packages/jgo/jgo.py", line 205, in run_and_combine_outputs
    return subprocess.check_output((command,) + args, stderr=subprocess.STDOUT)
  File "/Users/aimachine/anaconda3/envs/imagej/lib/python3.7/subprocess.py", line 389, in check_output
    **kwargs).stdout
  File "/Users/aimachine/anaconda3/envs/imagej/lib/python3.7/subprocess.py", line 481, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '('/Users/aimachine/anaconda3/envs/imagej/bin/mvn', '-B', '-f', '/Users/aimachine/.jgo/net/imagej/imagej/RELEASE+net.imglib-imglib2-imglyb-0.3.0/pom.xml', 'dependency:resolve')' returned non-zero exit status 1.

@hadim

So I added the imagej kernel using nb_conda to my list, thanks. Also used conda this time to install everything. But the last error I posted above is there if I run python from terminal or jupyter notebook alike.

Did I clone pyimagej from an old repo: https://github.com/imagej/pyimagej?


#16

Under the hood, pyimagej uses jrun which invokes mvn as a subprocess. You can see this from the final part of your error message:

subprocess.CalledProcessError: Command '('/Users/aimachine/anaconda3/envs/imagej/bin/mvn', '-B', '-f', '/Users/aimachine/.jgo/net/imagej/imagej/RELEASE+net.imglib-imglib2-imglyb-0.3.0/pom.xml', 'dependency:resolve')' returned non-zero exit status 1.

To troubleshoot further, we need to see the error the mvn is producing. You can probably find out by running that same command from the CLI manually:

/Users/aimachine/anaconda3/envs/imagej/bin/mvn -B -f /Users/aimachine/.jgo/net/imagej/imagej/RELEASE+net.imglib-imglib2-imglyb-0.3.0/pom.xml dependency:resolve

I hesitate to speculate exactly what the problem might be, since there are several possibilities, but for example, part of your local Maven repository cache might be corrupted.

Great. :+1: This is much simpler and less error-prone.

No, that is the correct repository. However, you should not need to even clone it at all, unless you want to hack on the pyimagej source. Because pyimagej is also on conda-forge!

conda create -n imagej pyimagej openjdk=8
conda activate imagej
jupyter notebook

:point_up: No need to use git here.


#17

@ctrueden Thanks so much, so first , running the command on terminal to see if my maven is corrupted, this is the start output of the command:

AIMachines-MacBook-Pro:pyimagej aimachine$ /Users/aimachine/anaconda3/envs/imagej/bin/mvn -B -f /Users/aimachine/.jgo/net/imagej/imagej/RELEASE+net.imglib-imglib2-imglyb-0.3.0/pom.xml dependency:resolve
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for net.imagej-BOOTSTRAPPER:imagej-BOOTSTRAPPER:jar:0
[WARNING] 'dependencies.dependency.version' for net.imagej:imagej:jar is either LATEST or RELEASE (both of them are being deprecated) @ line 10, column 97
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-jar-plugin/2.4/maven-jar-plugin-2.4.pom

Then it starts downloading from central and starts printing this output on the screen:


[INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-dependency-plugin/2.8/maven-dependency-plugin-2.8.pom
[INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-dependency-plugin/2.8/maven-dependency-plugin-2.8.pom (11 kB at 255 kB/s)
[INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-dependency-plugin/2.8/maven-dependency-plugin-2.8.jar
[INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-dependency-plugin/2.8/maven-dependency-plugin-2.8.jar (153 kB at 2.9 MB/s)
[INFO]
[INFO] ------------< net.imagej-BOOTSTRAPPER:imagej-BOOTSTRAPPER >-------------
[INFO] Building imagej-BOOTSTRAPPER 0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] Downloading from imagej.public: https://maven.imagej.net/content/groups/public/net/imagej/imagej/maven-metadata.xml
[INFO] Downloading from central: https://repo.maven.apache.org/maven2/net/imagej/imagej/maven-metadata.xml
[INFO] Downloading from saalfeldlab: https://saalfeldlab.github.io/maven/net/imagej/imagej/maven-metadata.xml

In the end starts to print something like:

[INFO] The following files have been resolved:
[INFO]    com.headius:invokebinder:jar:1.2:runtime
[INFO]    com.miglayout:miglayout:jar:swing:3.7.4:compile
[INFO]    net.imagej:imagej-plugins-tools:jar:0.3.1:runtime
[INFO]    org.netlib:blas:jar:0.8:runtime
[INFO]    org.scijava:scripting-scala:jar:0.2.1:runtime
[INFO]    joda-time:joda-time:jar:2.3:runtime

and then completes it with:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  01:45 min
[INFO] Finished at: 2019-02-01T21:01:17+01:00
[INFO] ------------------------------------------------------------------------
AIMachines-MacBook-Pro:pyimagej aimachine$

AND running that command FIXED IT!!!

So in conclusion my maven was broken! 

Thanks everyone for helping me out with this! @ctrueden @hadim @hanslovsky @imagejan


Analysis with ImageJ and Visualization in the Jupyter Notebook