Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing Qt binding after ultrack / napari installation #169

Open
JoOkuma opened this issue Dec 15, 2024 · 2 comments
Open

missing Qt binding after ultrack / napari installation #169

JoOkuma opened this issue Dec 15, 2024 · 2 comments

Comments

@JoOkuma
Copy link
Member

JoOkuma commented Dec 15, 2024

From @TeunHuijben

Installing with the repo instructions doesn't work out-of-the-box

conda create -n ultrack python=3.11 higra gurobi pytorch pyqt -c pytorch -c gurobi -c conda-forge
conda activate ultrack
pip install ultrack

Opening napari gave me Pyqt5 errors:

Traceback (most recent call last):
  File "/Users/teun.huijben/miniforge3/envs/ultrack/bin/napari", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/teun.huijben/miniforge3/envs/ultrack/lib/python3.11/site-packages/napari/__main__.py", line 574, in main
    _maybe_rerun_with_macos_fixes()
  File "/Users/teun.huijben/miniforge3/envs/ultrack/lib/python3.11/site-packages/napari/__main__.py", line 452, in _maybe_rerun_with_macos_fixes
    from napari._qt import API_NAME
  File "/Users/teun.huijben/miniforge3/envs/ultrack/lib/python3.11/site-packages/napari/_qt/__init__.py", line 18, in <module>
    raise ImportError(
ImportError: No Qt bindings could be found.

napari requires either PyQt5 (default) or PySide2 to be installed in the environment.

This can be fixed by installing napari[all] afterwards, but it's a bit puzzling because pyqt was installed in the first line (conda install ...)

@psobolewskiPhD
Copy link

So the reason this is happening is because ultrack has pyqt5 in the dependencies.
This is a pypi package not compatible with the conda-forge pyqt, resulting in a broken environment.
In general, we don't recommend depending on a specific Qt backend, but rather just qtpy:
https://napari.org/stable/plugins/building_a_plugin/best_practices.html#don-t-include-pyside2-or-pyqt5-in-your-plugin-s-dependencies
Likewise if someone has pyqt6 or pyside2 in their existing env, e.g. the napari bundle, then installing ultrack will also likely break the env.
Now, given the conda dependencies, maybe no-one would do such an install? 🤷
So your options are:

  1. remove the pyqt in the conda install line, leaving the potential issue with the pyqt5 dependency, but resolving the issue now by just having the pypi packaged Qt in the env.
  2. remove the explicit pyqt5 pypi dependency in favor of qtpy, and then leave the pyqt from conda-forge. You will want a Qt backend for tests though, because napari[testing] alone does not include one, so you can add pyqt5 to your testing set. You could also switch to something like ultrack[all] with pyqt5 mirroring napari[all] or a ultrack[pyq5] or something and then use that to have the backend be more explicit.

@JoOkuma
Copy link
Member Author

JoOkuma commented Dec 30, 2024

Thanks a lot, @psobolewskiPhD; I didn't know they were conflicting; it seems this is more common than I realized; we had similar issues with numba from different conda channels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants