royerlab / ultrack

Cell tracking and segmentation software
https://royerlab.github.io/ultrack
BSD 3-Clause "New" or "Revised" License
64 stars 7 forks source link

Improve napari installation instructions? #84

Closed tischi closed 4 months ago

tischi commented 4 months ago

I tried installing ultrack as specified in the README.txt but then trying to run napari throws the below error:

>>> napari.run()
Traceback (most recent call last):
  File "/g/cba/miniconda3/envs/ultrack_jupyter/lib/python3.10/site-packages/napari/_qt/__init__.py", line 8, in <module>
    from qtpy import API_NAME, QtCore
  File "/g/cba/miniconda3/envs/ultrack_jupyter/lib/python3.10/site-packages/qtpy/__init__.py", line 287, in <module>
    raise QtBindingsNotFoundError from None
qtpy.QtBindingsNotFoundError: No Qt bindings could be found

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/g/cba/miniconda3/envs/ultrack_jupyter/lib/python3.10/site-packages/napari/_event_loop.py", line 12, in run
    raise exc
  File "/g/cba/miniconda3/envs/ultrack_jupyter/lib/python3.10/site-packages/napari/_event_loop.py", line 2, in <module>
    from napari._qt.qt_event_loop import gui_qt, run
  File "/g/cba/miniconda3/envs/ultrack_jupyter/lib/python3.10/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.

With pip, you can install either with:
  $ pip install -U 'napari[all]'  # default choice
  $ pip install -U 'napari[pyqt5]'
  $ pip install -U 'napari[pyside2]'

With conda, you need to do:
  $ conda install -c conda-forge pyqt
  $ conda install -c conda-forge pyside2

Our heuristics suggest you are using 'pip' to manage your packages.
JoOkuma commented 4 months ago

Hi @tischi, napari doesn't come with a Qt backend.

pip install napari[all] should do the trick.

Or the other suggestion from the error message:

With pip, you can install either with:
  $ pip install -U 'napari[all]'  # default choice
  $ pip install -U 'napari[pyqt5]'
  $ pip install -U 'napari[pyside2]'

With conda, you need to do:
  $ conda install -c conda-forge pyqt
  $ conda install -c conda-forge pyside2
tischi commented 4 months ago

@JoOkuma I tried pip install napari[all] after following the instructions on the README and it still did not work. Could you somehow update the README instructions to include the qt backend?

tischi commented 4 months ago

I tried now:

conda create --prefix /g/cba/miniconda3/envs/ultrack_jupyter python=3.10 pip
conda activate ultrack_jupyter
pip install 'napari[all]' fire gurobipy git+https://github.com/royerlab/ultrack

And I can launch napari, but when I try to open one of the builtin sample images I am getting the error below:

>>> import napari
>>> napari.Viewer()
WARNING: QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-tischer'
libGL error: MESA-LOADER: failed to open swrast: /usr/lib/dri/swrast_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)
libGL error: failed to load driver: swrast
Viewer(camera=Camera(center=(0.0, 0.0, 0.0), zoom=1.0, angles=(0.0, 0.0, 90.0), perspective=0.0, mouse_pan=True, mouse_zoom=True), cursor=Cursor(position=(1.0, 1.0), scaled=True, size=1, style=<CursorStyle.STANDARD: 'standard'>), dims=Dims(ndim=2, ndisplay=2, last_used=0, range=((0, 2, 1), (0, 2, 1)), current_step=(0, 0), order=(0, 1), axis_labels=('0', '1')), grid=GridCanvas(stride=1, shape=(-1, -1), enabled=False), layers=[], help='', status='Ready', tooltip=Tooltip(visible=False, text=''), theme='dark', title='napari', mouse_over_canvas=False, mouse_move_callbacks=[], mouse_drag_callbacks=[], mouse_double_click_callbacks=[], mouse_wheel_callbacks=[<function dims_scroll at 0x7fac7d87dc60>], _persisted_mouse_event={}, _mouse_drag_gen={}, _mouse_wheel_gen={}, keymap={})
>>> Traceback (most recent call last):
  File "/g/cba/miniconda3/envs/ultrack_jupyter/lib/python3.10/site-packages/napari/_qt/menus/file_menu.py", line 229, in _add_sample
    self._win._qt_viewer.viewer.open_sample(plg, smp)
  File "/g/cba/miniconda3/envs/ultrack_jupyter/lib/python3.10/site-packages/napari/components/viewer_model.py", line 994, in open_sample
    added.extend(self._add_layer_from_data(*datum))
  File "/g/cba/miniconda3/envs/ultrack_jupyter/lib/python3.10/site-packages/napari/components/viewer_model.py", line 1395, in _add_layer_from_data
    layer = add_method(data, **(meta or {}))
  File "/g/cba/miniconda3/envs/ultrack_jupyter/lib/python3.10/site-packages/napari/utils/migrations.py", line 62, in _update_from_dict
    return func(*args, **kwargs)
  File "/g/cba/miniconda3/envs/ultrack_jupyter/lib/python3.10/site-packages/napari/components/viewer_model.py", line 901, in add_image
    self.layers.append(layer)
  File "/g/cba/miniconda3/envs/ultrack_jupyter/lib/python3.10/_collections_abc.py", line 1128, in append
    self.insert(len(self), value)
  File "/g/cba/miniconda3/envs/ultrack_jupyter/lib/python3.10/site-packages/napari/components/layerlist.py", line 167, in insert
    super().insert(index, new_layer)
  File "/g/cba/miniconda3/envs/ultrack_jupyter/lib/python3.10/site-packages/napari/utils/events/containers/_selectable_list.py", line 66, in insert
    super().insert(index, value)
  File "/g/cba/miniconda3/envs/ultrack_jupyter/lib/python3.10/site-packages/napari/utils/events/containers/_evented_list.py", line 195, in insert
    self.events.inserted(index=index, value=value)
  File "/g/cba/miniconda3/envs/ultrack_jupyter/lib/python3.10/site-packages/napari/utils/events/event.py", line 763, in __call__
    self._invoke_callback(cb, event if pass_event else None)
  File "/g/cba/miniconda3/envs/ultrack_jupyter/lib/python3.10/site-packages/napari/utils/events/event.py", line 801, in _invoke_callback
    _handle_exception(
  File "/g/cba/miniconda3/envs/ultrack_jupyter/lib/python3.10/site-packages/napari/utils/events/event.py", line 788, in _invoke_callback
    cb(event)
  File "/g/cba/miniconda3/envs/ultrack_jupyter/lib/python3.10/site-packages/napari/_qt/qt_viewer.py", line 656, in _on_add_layer_change
    self._add_layer(layer)
  File "/g/cba/miniconda3/envs/ultrack_jupyter/lib/python3.10/site-packages/napari/_qt/qt_viewer.py", line 666, in _add_layer
    vispy_layer = create_vispy_layer(layer)
  File "/g/cba/miniconda3/envs/ultrack_jupyter/lib/python3.10/site-packages/napari/_vispy/utils/visual.py", line 97, in create_vispy_layer
    return visual_class(layer)
  File "/g/cba/miniconda3/envs/ultrack_jupyter/lib/python3.10/site-packages/napari/_vispy/layers/image.py", line 279, in __init__
    super().__init__(
  File "/g/cba/miniconda3/envs/ultrack_jupyter/lib/python3.10/site-packages/napari/_vispy/layers/image.py", line 104, in __init__
    self._on_data_change()
  File "/g/cba/miniconda3/envs/ultrack_jupyter/lib/python3.10/site-packages/napari/_vispy/layers/image.py", line 141, in _on_data_change
    self._set_node_data(self.node, self.layer._data_view)
  File "/g/cba/miniconda3/envs/ultrack_jupyter/lib/python3.10/site-packages/napari/_vispy/layers/image.py", line 149, in _set_node_data
    node = self._layer_node.get_node(
  File "/g/cba/miniconda3/envs/ultrack_jupyter/lib/python3.10/site-packages/napari/_vispy/layers/image.py", line 62, in get_node
    raise ValueError("dtype does not match texture_format")
ValueError: dtype does not match texture_format
WARNING: QXcbConnection: XCB error: 3 (BadWindow), sequence: 1210, resource id: 6513641, major code: 40 (TranslateCoords), minor code: 0
tischi commented 4 months ago

I also tried installing napari before with conda, but then when I then tried to install ultrack via pip on top many core libraries like numpy and pandas are changed, which does not feel good....

JoOkuma commented 4 months ago

😓 this seems like a napari issue. I don't think numpy or pandas are the issue. It looks lower in the software stack.

Are you running in a node? Does it have OpenGL and other visualization drivers?