napari: Napari as a plugin depency can break napari conda install

šŸ› Bug

Napari as a plugin dependency can break napari conda install.

To Reproduce

Steps to reproduce the behaviour:

  1. Have a Python 3.9 fresh conda environment on Ubuntu 21.10 and installed napari through conda.
conda create -y -n napari-env-testing -c conda-forge python=3.9
conda activate napari-env-testing
conda install -c conda-forge napari
  1. Install a plugin that has napari in its dependencies.
pip install git+https://github.com/deep-finder/napari-deepfinder.git@194fef7d6c87141fdf656b4013dcef3f4c1ff033
  1. Try to launch napari:
napari

Expected behavior

It should not break the conda install, after removing napari from dependencies all works fine. After having removed the napari dependency, all works fine: when following the same procedure but installing the following plugin version:

pip install git+https://github.com/deep-finder/napari-deepfinder.git@7bcc71552458f5c2cd109fd25df0369e7b9cc267

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 24 (21 by maintainers)

Most upvoted comments

I use pyenv for manage environments. And all try to work on base anaconda env ends with tragedy.

Let me give a little bit of a higher-view summary here to let you know what I’m thinking:

in a fresh ubuntu install, Qt won’t actually work without additional libraries. This is why on github actions, we add this setup-qt-libs action that you use in your tests. What that does is install a bunch of libraries that are missing on ubuntu that are required to run a Qt GUI.

When you install pyqt from conda it comes with a ton of pre-compiled libraries on linux, so conda install pyqt should ā€œjust workā€ on ubuntu… but those libraries will be restricted to your conda environment. However, if you pip install PyQt, it doesn’t come with those libraries, so usually you will need to install them system wide using something like:

sudo apt-get install -y libegl1 libdbus-1-3 libxkbcommon-x11-0 \
    libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 \
    libxcb-render-util0 libxcb-xinerama0 libxcb-xinput0 libxcb-xfixes0

So, depending on your system libraries, and the order & source from which you’ve installed pyqt (i.e. from conda and/or from pip), you will usually run into one variant of the missing library issue.

Can you paste what error you get?

WARNING: Could not load the Qt platform plugin "xcb" in "" even though it was found.
14:10:29 WARNING Could not load the Qt platform plugin "xcb" in "" even though it was found.
WARNING: This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.

14:10:29 WARNING This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.

Abandon (core dumped)

thanks! Can you paste what error you get? It sounds kinda like you’re running into the classic xcb missing libraries issue, but it’s hard to say without more info (and it’s also not clear why that would be the case only when you also install napari).

If your error seems to come from qt, can you also try the following, and paste the output?

QT_DEBUG_PLUGINS=1 napari

I don’t see why I it is important to have napari in the dependencies of a plugin, as it’s purpose is to be used as a plugin, so in an environment where napari is already installed.

i understand where you’re coming from here. and it’s ā€œfineā€ if you want to have a package that only works in certain environments. I guess the main counterpoints are

  1. ā€œprincipleā€ 😃 … if you import a package, you should list it in your dependencies
  2. ability to declare version: if you eventually use a feature of napari that was introduced after some version, you would have to specify that in your deps
  3. A package really should be importable after installation. We routinely check things like npe2 by installing plugins into their own environments and testing stuff by importing them. If you can’t pip install and then import your top level module, then it’s sort of a broken package. We can (and do) maintain a list of packages that ā€œdon’t workā€ without napari, and inject that dependency when we test them, but it would be more ā€œcorrectā€ if those packages were importable on their own after installation

@cnstt I cannot reproduce the error on bare metal Ubuntu 21.10. So same version as you report. So if you still have an error please attach a stack trace (or another error report). I agree that most probably a source of error is installing PyQt5 again.

We may try even try to organize debug session on a zulip/zoom/gather to find real source of the problem.

But first, try to reproduce errors in environments created from scratch. Without any additional plugins.

And without removing PyQt5 (and maybe pyqtgraph) from deepfinder dependencies you will always have problems. Because the napari bundle works with PySide2 backend, so it creates a bigger problem.

I do not think that adding gui and curating imports is a big problem.