Sorry to post maybe a quite naive question. We are trying in Fiji to put a generic GUI around the scripts (like the batch in Fiji) previously done (in python or groovy) that launch locally a macro that automatically download the images onto our local pc, treat them and upload the results onto the database in a new dataset, with results attached. The groovy code or old Python (https://downloads.openmicroscopy.org/movies/omero-5-2/mov/fiji_scripting_demo.mov) works correctly. We would like to use the BlitzGateway as recommended when we wat to code in Python (https://docs.openmicroscopy.org/omero/5.5.1/developers/Python.html) but the initial command doesn’t work : “from omero.gateway import BlitzGateway” : ImportError: cannot import name BlitzGateway
What do we need to do? Is the way we want to proceed is correct? We work on Omero 5.4.10.
Many thanks for your help in advance,
To use the “BlitzGateway” you need to actually run this on Python (with the OMERO.py dependencies installed). But you’re running everything in Java, with Jython to give you the ability to use Python syntax and avoid a compile step.
Because of the confusion of using the Java OMERO API with Python syntax, we’ve moved away from Jython and prefer Groovy now.
Further to expand on what Will wrote, maybe you could profit from our examples on https://github.com/ome/training-scripts/tree/master/practical to get a better feeling about the ecosystem. The usage of this code is described for example in https://omero-guides.readthedocs.io/en/latest/fiji/docs/threshold_scripting.html. Sorry if you knew that already - note please that there is no Python example in the https://github.com/ome/training-scripts/tree/master/practical .
The python examples can be found in https://github.com/ome/training-notebooks - this is because, as Will remarked, you need a Python with OMERO.py dependencies, which you get in our training-notebooks environment (we built it there and it runs on our jupyter server) but not in the Fiji scripting window.
All the best
Sorry, I should have said in my previous post "there is no python example in the https://github.com/ome/training-scripts/tree/master/practical except for https://github.com/ome/training-scripts/tree/master/practical/python/server - which are the server-side python scripts - for these scripts, the python environment is of course installed directly on the OMERO.server itself.
Hi Will and Petr,
Many thanks for these advices and links. Sorry for my other basic questions… Where the Omero.py dependencies should be installed ? On our client PC or on the server? Should I download the"OMERO.py-5.4.10-ice35-b105" ? Where should I put the files, if I want to use a Python editor or the scriting interface of Fiji for example?
Apologies for the delayed response. We missed this and then it slipped down the listing at https://forum.image.sc/tags/omero. If that happens again, just add another reply to bring it to our attention.
Maybe you could give us some more background information about what you’re trying to achieve. You said that
What scripts are you referring to here? Unfortunately “scripts” can mean a lot of things. Are these ImageJ macros that have to be run in ImageJ/Fiji? In which case, you are really in the Java world and should avoid any confusion with Python. Originally we used jython scripting in Fiji but have switched to groovy because of this confusion.
No problem, many thanks, you answered my question before and I understood that groovy or Jython should be better. I was using this omero_batch_analysis.py : https://downloads.openmicroscopy.org/movies/omero-5-2/mov/fiji_scripting_demo.mov
juliomateos also helped me with OMERO_SIMcheck.py and the creation of Generic Interfaces from Fiji.
Despite all this, there is one thing that remain unclear for me about the Omero.py dependencies if I would like to use a Python editor and the Blitz Gateway. Where should these dependencies be installed ? On our client PC or on the server? They are taken
from the"OMERO.py-5.4.10-ice35-b105" ? What is the place of these files, for example?
You need those libraries on the client PC.
See https://docs.openmicroscopy.org/omero/5.5.1/developers/Python.html, although it refers to downloading the python libs as part of the whole server package.
You will also need Ice libraries as described in the OMERO.server installation and an OMERO server to connect to, which must be the same major version, i.e. 5.5.x.
You need to allow OMERO.py libs to be importable (there’s a bunch of ways to do this) and you need the Ice libs.
For example, using a new virtual python environment:
virtualenv omeropy source omeropy/bin/activate $ pip install zeroc-ice==3.6.5 python >>> import os >>> os.sys.path.append('/path/to/OMERO.py-5.4.10-ice35-b105/lib/python') >>> from omero.gateway import BlitzGateway >>> conn = BlitzGateway('username', 'password', port=4064, host='omero.server') >>> conn.connect() True
Hope that helps,