Connecting Napari to current Omero Server (5.4.9)

I’ve been playing around with Napari and was wondering if it is possible to write a python 3 client that can connect to our currently implemented server (5.4.9). I saw the example code posted recently, but it wasn’t clear to me whether this was only compatible with a development version of Omero server running python 3, or if it was just a dev version of the python 3 Omero API. On my own I haven’t been able to get the dependencies to line up.

1 Like

Maybe @will-moore can help with this one. Here is the post I think you are referring too - Napari loading images from OMERO I havn’t got experience with the omero server, but if there are things we can do on the #napari side of things to make this easier let us know

Hi, I think you’re going to have to use the up-coming OMERO 5.6.0 which will support python 3. See OMERO / Python 3 Rollout Plan. This is getting stable enough for developer testing now.

I’ve put my current omero-napari code at So far, this is very untested code (no-one apart from me has looked at it yet) and the OME team has not discussed it yet.
In fact, I’m aware of some issues with it, which I need to look into a bit more…

Let us know if you want any help trying the pre-releases of OMERO 5.6.0 and if you can help with omero-napari, that would be great!


1 Like

Hi @dstabley. There are not too many API changes between OMERO 5.4 and the upcoming OMERO 5.6 which is the target for the Python 3 migration. There’s some chance that we can help you to get it working. But to quote from OMERO / Python 3 Rollout Plan :

As a result, all future security patches will only be available for OMERO 5.6 and greater. For your own safety, it will be imperative that you be ready to upgrade your OMERO installation early in 2020.

I’d strongly encourage you to drive an upgrade of your OMERO to 5.6. We will definitely help with that. :slightly_smiling_face:

All the best,

for what it’s worth, I tried @will-moore’s code last night with our OMERO instance and it worked great! (as usual, the only difficult part was getting the zeroc-ice dependency installed which required some finagling of my command line tools to compile correctly).
A couple images did throw IndexErrors, but I haven’t had time to see whether that was an API mismatch error or something else.

1 Like

@talley @will-moore @joshmoore I can get this far into it but the final pip install -e . errors out.

(naparitest) C:\Users\dstabley\omero-py>pip install -e .
Obtaining file:///C:/Users/dstabley/omero-py
    ERROR: Command errored out with exit status 1:
     command: 'C:\ProgramData\Anaconda3\envs\naparitest\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\dstabley\\omero-py\\'"'"'; __file__='"'"'C:\\Users\\dstabley\\omero-py\\'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);'"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info
         cwd: C:\Users\dstabley\omero-py\
    Complete output (42 lines):
    running egg_info
    creating target\omero_py.egg-info
    writing target/omero_py.egg-info\PKG-INFO
    writing dependency_links to target/omero_py.egg-info\dependency_links.txt
    writing requirements to target/omero_py.egg-info\requires.txt
    writing top-level names to target/omero_py.egg-info\top_level.txt
    writing manifest file 'target/omero_py.egg-info\SOURCES.txt'
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\dstabley\omero-py\", line 219, in <module>
        'devtarget': DevTargetCommand,
      File "C:\ProgramData\Anaconda3\envs\naparitest\lib\site-packages\setuptools\", line 145, in setup
        return distutils.core.setup(**attrs)
      File "C:\ProgramData\Anaconda3\envs\naparitest\lib\distutils\", line 148, in setup
      File "C:\ProgramData\Anaconda3\envs\naparitest\lib\distutils\", line 955, in run_commands
      File "C:\ProgramData\Anaconda3\envs\naparitest\lib\distutils\", line 974, in run_command
      File "C:\ProgramData\Anaconda3\envs\naparitest\lib\site-packages\setuptools\command\", line 296, in run
      File "C:\ProgramData\Anaconda3\envs\naparitest\lib\site-packages\setuptools\command\", line 303, in find_sources
      File "C:\ProgramData\Anaconda3\envs\naparitest\lib\site-packages\setuptools\command\", line 534, in run
      File "C:\ProgramData\Anaconda3\envs\naparitest\lib\site-packages\setuptools\command\", line 570, in add_defaults
      File "C:\ProgramData\Anaconda3\envs\naparitest\lib\site-packages\setuptools\command\", line 34, in add_defaults
      File "C:\ProgramData\Anaconda3\envs\naparitest\lib\site-packages\setuptools\command\", line 127, in _add_defaults_python
        build_py = self.get_finalized_command('build_py')
      File "C:\ProgramData\Anaconda3\envs\naparitest\lib\distutils\", line 299, in get_finalized_command
      File "C:\ProgramData\Anaconda3\envs\naparitest\lib\distutils\", line 107, in ensure_finalized
      File "C:\ProgramData\Anaconda3\envs\naparitest\lib\site-packages\setuptools\command\", line 34, in finalize_options
      File "C:\ProgramData\Anaconda3\envs\naparitest\lib\distutils\command\", line 55, in finalize_options
        self.package_dir[name] = convert_path(path)
      File "C:\ProgramData\Anaconda3\envs\naparitest\lib\distutils\", line 127, in convert_path
        raise ValueError("path '%s' cannot end with '/'" % pathname)
    ValueError: path 'target/' cannot end with '/'
ERROR: Command errored out with exit status 1: python egg_info Check the logs for full command output.

Ah, Windows. Looks like a issue has slipped in in the migration. We’ll look into getting a test environment set up. In the meantime, you might try removing the / on line 202 ("target/"):

git diff
diff --git a/ b/
index e4241b68..3bcc80b0 100644
--- a/
+++ b/
@@ -199,7 +199,7 @@ setup(
     author="The Open Microscopy Team",
-    package_dir={"": "target/"},
+    package_dir={"": "target"},


@joshmoore That did it, thanks!

1 Like

Thanks for letting us know. ~J

@joshmoore I think this is completely unrelated, but I am now getting the following when actually trying to connect:

Traceback (most recent call last):
  File "c:/Users/dstabley/Downloads/1.0/1.0/", line 10, in <module>
    image = conn.getObject("Image", IMAGE_ID)
  File "c:\users\dstabley\omero-py\target\omero\gateway\", line 3269, in getObject
    result = self.getQueryService().findByQuery(
  File "c:\users\dstabley\omero-py\target\omero\gateway\", line 2564, in getQueryService
    return self._proxies['query']
  File "c:\users\dstabley\omero-py\target\omero\gateway\", line 1502, in __getitem__
    raise Ice.ConnectionLostException
Ice.ConnectionLostException: Ice.ConnectionLostException:
recv() returned zero

Hey @dstabley,

I wouldn’t think this is related to the migration to Python 3, but it may stem from using an older version of OMERO. Is there any related standard out/err?


We watched the server activity through SSH as it was trying to connect and didn’t see anything, it looks like it isn’t contacting the server at all, we didn’t see anything from the omero side. If I remove all of the code and try a simple connect and close through BlitzGateway I get the following:

C:\Users\dstabley>C:/ProgramData/Anaconda3/envs/naparitest/python.exe c:/Users/dstabley/Downloads/1.0/1.0/
closing conn…
WARNING:omero.client:…Ignoring error in client.del:<class ‘Ice.SecurityException’>

SecurityException looks to be new for this thread. Can you possibly share your ~J.

It is identical to the script Will posted, just using our info and an image that is in our Omero instance:

import napari
from vispy.color import Colormap
import numpy
from omero.gateway import BlitzGateway
conn = BlitzGateway(“username”, “password”, port=4064, host=“”)

IMAGE_ID = 8803
image = conn.getObject(“Image”, IMAGE_ID)

def get_z_stack(img, c=0, t=0):
zct_list = [(z, c, t) for z in range(img.getSizeZ())]
pixels = image.getPrimaryPixels()
return numpy.array(list(pixels.getPlanes(zct_list)))

with napari.gui_qt():
viewer = napari.Viewer()

for c, channel in enumerate(image.getChannels()):
    print('loading channel %s' % c)
    data = get_z_stack(image, c=c)
    # use current rendering settings from OMERO
    color = channel.getColor().getRGB()
    color = [r/256 for r in color]
    cmap = Colormap([[0, 0, 0], color])
    # Z-scale for 3D viewing
    size_x = image.getPixelSizeX()
    size_z = image.getPixelSizeZ()
    z_scale = size_z / size_x
    viewer.add_image(data, blending='additive',
                     colormap=('from_omero', cmap),
                     scale=[1, z_scale, 1, 1],

print(‘closing conn…’)


I’ve tried connecting to an OMERO 5.4 server from my omero-py 5.6 virtualenv and I can’t reproduce any SecurityException. We can only guess it might be some issue with Windows or SSL related (I can’t easily test on Windows).

Hopefully upgrading to OMERO 5.6 will help (we will have our first release candidate out soon) and we will certainly test Windows connection to OMERO 5.6.