Python scripting in FiJi with Omero and use of the BlitzGateway

Dear all,
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 ( works correctly. We would like to use the BlitzGateway as recommended when we wat to code in Python ( 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,
Best regards,

Hi Frédéric,

To use the “BlitzGateway” you need to actually run this on Python (with the 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.



Hi Frédéric,
Further to expand on what Will wrote, maybe you could profit from our examples on to get a better feeling about the ecosystem. The usage of this code is described for example in Sorry if you knew that already - note please that there is no Python example in the .
The python examples can be found in - this is because, as Will remarked, you need a Python with 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


Hi Frédéric,

Sorry, I should have said in my previous post "there is no python example in the except for - 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 dependencies should be installed ? On our client PC or on the server? Should I download the"" ? Where should I put the files, if I want to use a Python editor or the scriting interface of Fiji for example?
Best regards,


Apologies for the delayed response. We missed this and then it slipped down the listing at 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.


1 Like

Hi Will,

No problem, many thanks, you answered my question before and I understood that groovy or Jython should be better. I was using this :
juliomateos also helped me with and the creation of Generic Interfaces from Fiji.

Despite all this, there is one thing that remain unclear for me about the 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"" ? What is the place of these files, for example?

Best regards,


You need those libraries on the client PC.

See, 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 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

>>> import os
>>> os.sys.path.append('/path/to/')
>>> from omero.gateway import BlitzGateway
>>> conn = BlitzGateway('username', 'password', port=4064, host='omero.server')
>>> conn.connect()

Hope that helps,


Soon, when OMERO 5.6 is released, with decoupled python libs (, you’ll be able to install the libs with with:

pip install omero-py

See OMERO / Python 3 Rollout Plan

1 Like