question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Viewer console not working when running under ipython

See original GitHub issue

🐛 Bug

If I run napari from an ipython console with the %gui qt magic then I can’t access the ipython console from the viewer. Running from python rather than ipython, the console works as expected

To Reproduce

The following opens a viewer, the error is produced when trying to access the console from the viewer

(base) ➜  napari git:(master) ✗ conda activate napari
(napari) ➜  napari git:(master) ✗ ipython
Python 3.9.5 | packaged by conda-forge | (default, Jun 19 2021, 00:27:35) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.24.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: %gui qt

In [2]: %run examples/add_image.py

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
~/Programming/napari/napari/utils/action_manager.py in <lambda>()
     52     def callable(self, context):
     53         if not hasattr(self, '_command_with_context'):
---> 54             self._command_with_context = lambda: call_with_context(
     55                 self.command, context
     56             )

~/Programming/napari/napari/utils/action_manager.py in call_with_context(function, context)
     41     ]
     42     ctx = {k: v for k, v in context.items() if k in context_keys}
---> 43     return function(**ctx)
     44 
     45 

~/Programming/napari/napari/_qt/qt_viewer.py in toggle_console_visibility(self, event)
    724         """
    725         # force instantiation of console if not already instantiated
--> 726         _ = self.console
    727 
    728         viz = not self.dockConsole.isVisible()

AttributeError: 'QtViewer' object has no attribute 'console'

The following works fine

(napari) ➜  napari git:(master) ✗ python examples/add_image.py 

This used to work fine on my system, not sure exactly when it broke… will have to do some searching

napari --info

napari: 0.4.10.dev0+g609fd9f4.d20210623
Platform: macOS-11.2.1-x86_64-i386-64bit
System: MacOS 11.2.1
Python: 3.9.5 | packaged by conda-forge | (default, Jun 19 2021, 00:27:35)  [Clang 11.1.0 ]
Qt: 5.15.2
PyQt5: 5.15.4
NumPy: 1.21.0
SciPy: 1.7.0
Dask: 2021.06.2
VisPy: 0.6.6

OpenGL:
  - GL version:  2.1 Metal - 71.0.7
  - MAX_TEXTURE_SIZE: 16384

Screens:
  - screen 1: resolution 1440x900, scale 2.0

Plugins:
  - console: 0.0.3
  - scikit-image: 0.4.10.dev0+g609fd9f4.d20210623
  - svg: 0.1.5

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
brisvagcommented, Jun 23, 2021

Console indeed never worked from IPython! It was one of the reasons why I was interested in doing #2378.

1reaction
tlambert03commented, Jun 23, 2021

I know there’s been some discussion somewhere about disabling that button when running via ipython. still a good idea…

As for pycharm, I’ll need to play with it (don’t have much experience with it). Maybe we can screen share for that?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Viewer problem 'non-GUI backend' with Spyder's IPython ...
Hello, I recently updated to Spyder 5 on MacOS and have been using FiPy in combination with Spyder for a long time.
Read more >
Spyder 4.2.5 - iPython Console Not Working With Python 3.8.0
And every time I execute the command pip install spyder-kernels. It show the message: Fatal error in launcher: Unable to create process ......
Read more >
iPython console gets totally unresponsive when using large ...
After the update PyCharm would crash due to running out of memory when debugging something that had a large DataFrame. I could on...
Read more >
IPython Console — Spyder 5 documentation
To connect to a kernel on a remote machine,. Launch a Spyder kernel on the remote host if one is not already running,...
Read more >
IPython Console Plugin
To run the IPython Console Plugin, select one of the accessible items listed in the Application Tree View - either an application or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found