How to install and run ImagePy?

conda
imagepy

#1

@yxdragon

I installed imagepy 0.17 from conda-forge into a dedicated conda environment using conda create -n imagepy imagepy. However, I cannot figure out how to launch ImagePy after activating the environment. The imagepy conda package does not install any CLI script hooks, so e.g. imagepy does not do anything. Attempting to import imagepy in Python yields the following error:

python -c 'import imagepy'                                                                            #  0 {2019-01-04 15:02:21}
Traceback (most recent call last):
  File "/usr/local/miniconda3/envs/imagepy/lib/python3.6/site-packages/wx/lib/pubsub/__init__.py", line 38, in <module>
    from pubsub import *
ModuleNotFoundError: No module named 'pubsub'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/miniconda3/envs/imagepy/lib/python3.6/site-packages/imagepy/__init__.py", line 10, in <module>
    from .ui.imagepy import ImagePy
  File "/usr/local/miniconda3/envs/imagepy/lib/python3.6/site-packages/imagepy/ui/imagepy.py", line 9, in <module>
    from .. import IPy, root_dir
  File "/usr/local/miniconda3/envs/imagepy/lib/python3.6/site-packages/imagepy/IPy.py", line 11, in <module>
    from wx.lib.pubsub import pub
  File "/usr/local/miniconda3/envs/imagepy/lib/python3.6/site-packages/wx/lib/pubsub/__init__.py", line 41, in <module>
    raise ImportError(msg)
ImportError: Stand-alone pubsub not found. Use `pip install PyPubSub`

Furthermore, I do not understand the installation instructions in the README of the GitHub repository. It is possible to easily get ImagePy up and running in a conda environment?


ImagePy want to join forum.image.sc
#2

Hi
In our country, most student use Windows, So ImagePy give a rar file, just download and unzip it will be ok.

On Linux, It is a little trouble indeed, That’s because the wxpython.
for ImagePy want to have a free lisence, So I must choose wx, not pyqt.
and wx is a native ui framework, It can be installed by pip on Windows or Mac,
but for diffrent publish Linux, and diffrent gtk, There are no general wheel for Linux.
you can install here

because the pip and conda can not solve the wx trouble, So I did not update it for a long time.
So please get the newest code from github. I know Linux is very important for science, but I can not solve it so far. But wxpython upgrades frequently, I wish it could support pip and canda for Linux soon.


#3

Just to share my experience. I managed to install ImagePy and run on mint18 (similar to Ubuntu18)
Indeed, it was a pain installing it. To give some hints for other who want to have a go on ImagePy: nor the canonical wxpython in pip or in conda works. You really have to install manually with pip
pip install -U -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/{YOUR_DISTRO} wxPython
To find the availiable versions of wxpython, here is their official site
https://extras.wxpython.org/wxPython4/extras/linux/gtk3/

@yxdragon also uploadded a package to install wxpython. However, it doesn’t support all the linux versions. But it should work for Ubuntu
pip install wxinstaller
hope you can run it on your computer. Finger crossed :joy:


#4

BTW, it seems that in the new README, we accidentally removed How to run imagepy part…shame.
We will add that soon.
In short, Linux user can cd into the root of repo and run with:
python -m imagepy

For mac, use pythonw instead
pythonw -m imagepy

regards.


#5

I had a quick look at the conda-forge recipe.
The issue seems to be the dependencies offloaded to yum:

This will make the build pass; but the dependencies need to be present on the user system independent of conda.
It should be possible to include these dependencies into conda though, as both are available:
https://anaconda.org/conda-forge/gtk2
https://anaconda.org/anaconda/webkitgtk-cos6-x86_64
https://anaconda.org/anaconda/webkitgtk-devel-cos6-x86_64

@yxdragon
Let me know if you are interested in a pull request to the imgagepy conda feedstock and I could try to fix this.

Edit:
Ok, I had a closer look and the gtk dependencies may not be the actual problem.
What I wrote above is true, but most systems should have the necessary gtk dependencies (def. the case for Ubuntu).

The problem @ctrueden encountered is caused by the missing pybubsub dependency:


(As a sidenote I have no idea how the conda-forge tests pass without it).

Unfortunately this is not yet available on conda-forge, only on some third-party channel:
https://anaconda.org/ivoflipse/pypubsub

So for now, the package can be installed via

conda install -c conda-forge -c ivoflipse imagepy pypubsub

(Tested on ubuntu 16).

The pypubsub package should be moved to conda-forge though, see


#6

I am very glad to make imagepy avaliable on conda and pip. But as I known, pypubsub is a sub model of wxpython, And as wx official say, wx can not be install by a simple pip/conda command on linux. we must choose the wheel corresponding your system and gtk version.

So I help to build a project named wxpython-installer, It is a blank package, but in the setup.py, check the system, and download the right wheel, and pip install it. It is not a standard method.

I am very glad to try it, but I do not trust that we can fix it. Please tell me what need I do.


#7

@yxdragon As far as I understand, pypubsub is a standalone package and it should not be difficult to put it on conda-forge.
There is a wxpython package on conda-forge already, but for some reason it skips the pypubsub dependency.

If we can bring pypubsub on conda-forge, you would only need
to add it to the dependencies of the imagepy package to make it work.

For now, I don’t think that anything needs to be done about the gtk dependency. Most linux systems come with a sufficient gtk version and if not, it can be installed via conda separately.

Edit:
On linux, the wxpython package will pull gtk from conda anyways:


So there is no need to worry about this.


#8

Pypubsub is on conda-forge now.
@yxdragon I have made a PR to the imagepy feedstock that adds it to the dependencies:

You can merge it (given CI passes) and then the conda imagepy package should work.


#9

Thanks @constantinpape and @BioinfoTongLI!

I have filed Image-Py/imagepy#42 adding a conda environment.yml to the ImagePy repository, to enable launching ImagePy from source as follows:

git clone git://github.com/Image-Py/imagepy
cd imagepy
conda env create
conda activate imagepy
python -m imagepy

I was able to launch ImagePy on my macOS system (substituting pythonw for python) using this approach.

I do receive some errors upon launch:

some plugin may be not loaded, but not affect otheres!

>>> menus/Plugins/Surf                                surf_plg.py         No module named ‘cv2’

>>> menus/Kit3D/Viewer 3D                             surface_plgs.py     No module named ‘moderngl’

>>> menus/Kit3D/Viewer 3D                             colorpts_plg.py     No module named ‘moderngl’

>>> menus/Kit3D/Viewer 3D                             demo_plgs.py        No module named ‘moderngl’

>>> menus/Kit3D/Network 3D                            toolkit3d_plgs.py   No module named ‘moderngl’

tools not loaded:

>>> tools/Toolkit3D                                   cursor3d_tol        No module named ‘moderngl’

Are these expected?


#10

@ctrueden
Adding opencv to your enviroment file would be easy, it’s on conda-forge:
https://anaconda.org/conda-forge/opencv
ModernGL is not on conda, but it’s on pip and apparently does not have complicated dependencies, so you could pull it into the env with pip, see second example in the docs:
https://conda.io/docs/user-guide/tasks/manage-environments.html#creating-an-environment-file-manually


#11

I believe so. Those are the packages he considered as “optional”.
I confirm that I do get those things too at each launch. So does the others.
Maybe it should be popped up only if users want to use those “inexisting” packages? I don’t know.

It seems your solutions are great @constantinpape and @ctrueden.
Unfortunately, I’m not maintainer of ImagePy. We will have to wait for him.
Knowing that @yxdragon is not an academic researcher. He runs his own company. I’m not sure when will he have the time to review it.


#12

@constantinpape Thanks, I force-pushed the PR to include opencv, as well as ModernGL via pip.


#13

OK, Thanks very much(I am not sure it works, have a try later:joy:)

can not pass the CI:

conda_build.exceptions.DependencyNeedsBuildingError: Unsatisfiable dependencies for platform linux-64: {“pypubsub[version=’>=4.0’]”}


#14

ImagePy is a pure plugin system, if the main framework can launch, that will be ok. The error upon launch is reporting some plugin not loaded. moderngl is for 3d viewer. not on conda-forge. opencv is ok, but I just write one demo plugins to show that ImagePy can work with opencv, so not needed.

about ImagePy’s plugin install, you can use Plugins > Install > Install Plugin. Then input a plugin project’s git url, then click ‘OK’, ImagePy would download and Install the plugin, And use pip to solve the requirements. there are some demo project on github.

https://github.com/Image-Py/IBook
https://github.com/Image-Py/opencv-plgs
https://github.com/Image-Py/itk-plgs

you can try to install the IBook, It is a demo set like a tutorial.


#15

Sorry! OpenCV is 3-10 times faster than skimage and ImageJ, but it is not born and bred in python. It is very useful for industry, but for science, I think it is not friendly (not supporting arbitrary data type and dimension), So I did not want to depend on CV. But we can contribute in the opencv plugins project:
https://github.com/Image-Py/opencv-plgs

another trouble is, ImagePy support python2.7 and python3.x, but moderngl only support 3.x, So If add moderngl dependence means give up 2.7.

Please give some advice, Should I give up 2.7?


#16

Yes, I would give up on python 2.7.
It will be EOL after this year.


#17

Could you please provide me link of the rar file for windows? thanks.


#19

ImagePy for win, unzip, and run the ImagePy.bat. When the mainframe show, you need use Plugins > Update Software first, for the rar file is not update everyday.

It is in a cloud platform in Chinese, very fast, but may not friendly for English user, do you know some free cloud platform?


#20

Many thanks for your help. Could you please provide your personal email address? I need to discuss some issues with you. Thanks in advance for your kind cooperation.

Best Regards

Asif


#21

mail: yxdragon@imagepy.org