Skip to content

Add isatty method to StreamWriter + eval GUI fix#3314

Open
yyexela wants to merge 4 commits into
DeepLabCut:mainfrom
yyexela:fix_is_atty_attribute_error
Open

Add isatty method to StreamWriter + eval GUI fix#3314
yyexela wants to merge 4 commits into
DeepLabCut:mainfrom
yyexela:fix_is_atty_attribute_error

Conversation

@yyexela
Copy link
Copy Markdown

@yyexela yyexela commented May 6, 2026

When running the GUI of DeepLabCut in the terminal using python -m deeplabcut I get the following error:

    File "/Users/alexey/Git/DeepLabCut/deeplabcut/gui/tabs/label_frames.py", line 135, in label_frames
      _ = launch_napari(folder)
          ^^^^^^^^^^^^^^^^^^^^^
    File "/Users/alexey/Git/DeepLabCut/deeplabcut/gui/widgets.py", line 30, in launch_napari
      viewer = napari.Viewer()
               ^^^^^^^^^^^^^^^
    File "/Users/alexey/.virtualenvs/bio/lib/python3.11/site-packages/napari/viewer.py", line 67, in __init__
      self._window = Window(self, show=show)
                     ^^^^^^^^^^^^^^^^^^^^^^^
    File "/Users/alexey/.virtualenvs/bio/lib/python3.11/site-packages/napari/_qt/qt_main_window.py", line 742, in __init__
      self._add_menus()
    File "/Users/alexey/.virtualenvs/bio/lib/python3.11/site-packages/napari/_qt/qt_main_window.py", line 1047, in _add_menus
      self.window_menu = build_qmodel_menu(
                         ^^^^^^^^^^^^^^^^^^
    File "/Users/alexey/.virtualenvs/bio/lib/python3.11/site-packages/napari/_qt/_qapp_model/_menus.py", line 32, in build_qmodel_menu
      return QModelMenu(
             ^^^^^^^^^^^
    File "/Users/alexey/.virtualenvs/bio/lib/python3.11/site-packages/app_model/backends/qt/_qmenu.py", line 54, in __init__
      self.rebuild()
    File "/Users/alexey/.virtualenvs/bio/lib/python3.11/site-packages/app_model/backends/qt/_qmenu.py", line 93, in rebuild
      _rebuild(
    File "/Users/alexey/.virtualenvs/bio/lib/python3.11/site-packages/app_model/backends/qt/_qmenu.py", line 314, in _rebuild
      action = QMenuItemAction.create(item, app=app, parent=qapp)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/Users/alexey/.virtualenvs/bio/lib/python3.11/site-packages/app_model/backends/qt/_qaction.py", line 182, in create
      cls._cache[cache_key] = obj = cls(menu_item, app, parent)
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/Users/alexey/.virtualenvs/bio/lib/python3.11/site-packages/app_model/backends/qt/_qaction.py", line 148, in __init__
      super().__init__(menu_item.command, app, parent)
    File "/Users/alexey/.virtualenvs/bio/lib/python3.11/site-packages/app_model/backends/qt/_qaction.py", line 100, in __init__
      self._refresh()
    File "/Users/alexey/.virtualenvs/bio/lib/python3.11/site-packages/app_model/backends/qt/_qaction.py", line 121, in _refresh
      self.setChecked(_current())
                      ^^^^^^^^^^
    File "/Users/alexey/.virtualenvs/bio/lib/python3.11/site-packages/in_n_out/_store.py", line 804, in _exec
      result = func(**bound.arguments)
               ^^^^^^^^^^^^^^^^^^^^^^^
    File "/Users/alexey/.virtualenvs/bio/lib/python3.11/site-packages/napari/_qt/_qapp_model/qactions/_toggle_action.py", line 47, in get_current
      dock_widget_prop = getattr(window._qt_viewer, dock_widget)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/Users/alexey/.virtualenvs/bio/lib/python3.11/site-packages/napari/_qt/qt_viewer.py", line 325, in dockLayerList
      layerListLayout.addWidget(self.viewerButtons)
                                ^^^^^^^^^^^^^^^^^^
    File "/Users/alexey/.virtualenvs/bio/lib/python3.11/site-packages/napari/_qt/qt_viewer.py", line 313, in viewerButtons
      self._viewerButtons = QtViewerButtons(self.viewer)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/Users/alexey/.virtualenvs/bio/lib/python3.11/site-packages/napari/_qt/widgets/qt_viewer_buttons.py", line 180, in __init__
      if in_ipython() or in_jupyter() or in_python_repl():
         ^^^^^^^^^^^^
    File "/Users/alexey/.virtualenvs/bio/lib/python3.11/site-packages/napari/utils/misc.py", line 67, in in_ipython
      from IPython import get_ipython
    File "/Users/alexey/.virtualenvs/bio/lib/python3.11/site-packages/IPython/__init__.py", line 56, in <module>
      from .terminal.embed import embed
    File "/Users/alexey/.virtualenvs/bio/lib/python3.11/site-packages/IPython/terminal/embed.py", line 16, in <module>
      from IPython.terminal.interactiveshell import TerminalInteractiveShell
    File "/Users/alexey/.virtualenvs/bio/lib/python3.11/site-packages/IPython/terminal/interactiveshell.py", line 11, in <module>
      from IPython.core.kitty import (
    File "/Users/alexey/.virtualenvs/bio/lib/python3.11/site-packages/IPython/core/kitty.py", line 36, in <module>
      supports_kitty_graphics = _supports_kitty_graphics()
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/Users/alexey/.virtualenvs/bio/lib/python3.11/site-packages/IPython/core/kitty.py", line 13, in _supports_kitty_graphics
      if not sys.stdout.isatty():
             ^^^^^^^^^^^^^^^^^
  AttributeError: 'StreamWriter' object has no attribute 'isatty'

The fix for this is simple, since StreamWriter replaces sys.stdout it doesn't implement isatty(), which IPython 9.x calls at module import time in kitty.py. To fix this, we need to add isatty() to StreamWriter.

I'm running macOS 15.7.4 24G517 arm64 on Apple M4. I installed deeplabcut using pip.

@yyexela
Copy link
Copy Markdown
Author

yyexela commented May 6, 2026

Added another bug fix for evaluating the network

  1. evaluate_network.py:217 calls launch_napari(image_dir) — passing a directory.
  2. launch_napari calls viewer.open(image_dir, plugin="napari-deeplabcut").
  3. napari-deeplabcut selects get_folder_parser for directories, which calls
  looks_like_dlc_labeled_folder.
  4. That heuristic requires either DLC annotation files (CollectedData*.h5/.csv, machinelabels*.h5/.csv)
  or labeled-data in the path — neither is true for an evaluation-results-pytorch/…/LabeledImages_…
  folder.
  5. get_folder_parser returns None, so napari-deeplabcut yields no data and napari raises the ValueError.

  The fix is to pass labeled_images (the already-collected list of .png files) instead of the directory.
  That routes through get_image_reader which just checks the file extension and works fine.

@C-Achard C-Achard self-assigned this May 7, 2026
@C-Achard C-Achard added GUI issues relating to GUI napari-dlc Related to napari-deeplabcut (labeling workflow, crop, frame extraction...) labels May 7, 2026
@C-Achard C-Achard changed the title Mac M4 GUI Bug Fix dd isatty method to StreamWriter + eval GUI fix May 7, 2026
@C-Achard C-Achard changed the title dd isatty method to StreamWriter + eval GUI fix Add isatty method to StreamWriter + eval GUI fix May 7, 2026
Copy link
Copy Markdown
Collaborator

@C-Achard C-Achard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @yyexela,

Thanks for the PR, the missing isatty was already fixed in #3307, but happy to merge this one instead.
The other fix is good too, thanks for catching that!

Best,
Cyril

@deruyter92 deruyter92 self-requested a review May 7, 2026 11:30
@C-Achard C-Achard requested review from AlexEMG and MMathisLab May 7, 2026 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

GUI issues relating to GUI napari-dlc Related to napari-deeplabcut (labeling workflow, crop, frame extraction...)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants