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.

❓ Questions and Help

[X] I have searched the documentation

I am working on a GUI using Napari and updated both Napari to the newest version. I am now having trouble running even the demo code. I have made a new environment with python 3.9 and only napari (installed using pip install napari[all]).

Demo code I am trying to run from the docs:

import napari
import skimage.data
import skimage.filters
from napari.types import ImageData

from magicgui import magicgui


# turn the gaussian blur function into a magicgui
# - `auto_call` tells magicgui to call the function when a parameter changes
# - we use `widget_type` to override the default "float" widget on sigma,
#   and provide a maximum valid value.
# - we contstrain the possible choices for `mode`
@magicgui(
    auto_call=True,
    sigma={"widget_type": "FloatSlider", "max": 6},
    mode={"choices": ["reflect", "constant", "nearest", "mirror", "wrap"]},
    layout='horizontal'
)
def gaussian_blur(layer: ImageData, sigma: float = 1.0, mode="nearest") -> ImageData:
    """Apply a gaussian blur to ``layer``."""
    if layer is not None:
        return skimage.filters.gaussian(layer, sigma=sigma, mode=mode)

# create a viewer and add some images
viewer = napari.Viewer()
viewer.add_image(skimage.data.astronaut().mean(-1), name="astronaut")
viewer.add_image(skimage.data.grass().astype("float"), name="grass")

# Add it to the napari viewer
viewer.window.add_dock_widget(gaussian_blur)
# update the layer dropdown menu when the layer list changes
viewer.layers.events.changed.connect(gaussian_blur.reset_choices)

napari.run()

Error I get:

(napari-test) C:\Users\qi2lab\Documents\GitHub\OPM>C:/Users/qi2lab/miniconda3/envs/napari-test/python.exe c:/Users/qi2lab/Documents/GitHub/OPM/test_napari.py
Traceback (most recent call last):
  File "c:\Users\qi2lab\Documents\GitHub\OPM\test_napari.py", line 20, in <module>
    def gaussian_blur(layer: ImageData, sigma: float = 1.0, mode="nearest") -> ImageData:
  File "C:\Users\qi2lab\miniconda3\envs\napari-test\lib\site-packages\magicgui\_magicgui.py", line 241, in inner_func
    return magic_class(func, **kwargs)
  File "C:\Users\qi2lab\miniconda3\envs\napari-test\lib\site-packages\magicgui\widgets\_function_gui.py", line 162, in __init__
    widgets=list(sig.widgets(app).values()),
  File "C:\Users\qi2lab\miniconda3\envs\napari-test\lib\site-packages\magicgui\signature.py", line 222, in widgets
    {n: p.to_widget(app) for n, p in self.parameters.items()}
  File "C:\Users\qi2lab\miniconda3\envs\napari-test\lib\site-packages\magicgui\signature.py", line 222, in <dictcomp>
    {n: p.to_widget(app) for n, p in self.parameters.items()}
  File "C:\Users\qi2lab\miniconda3\envs\napari-test\lib\site-packages\magicgui\signature.py", line 139, in to_widget
    widget = create_widget(
  File "C:\Users\qi2lab\miniconda3\envs\napari-test\lib\site-packages\magicgui\widgets\_bases\create_widget.py", line 91, in create_widget
    widget = wdg_class(**kwargs)
  File "C:\Users\qi2lab\miniconda3\envs\napari-test\lib\site-packages\magicgui\widgets\_concrete.py", line 164, in __init__
    super(cls, self).__init__(**kwargs)
  File "C:\Users\qi2lab\miniconda3\envs\napari-test\lib\site-packages\magicgui\widgets\_bases\categorical_widget.py", line 25, in __init__
    super().__init__(**kwargs)
  File "C:\Users\qi2lab\miniconda3\envs\napari-test\lib\site-packages\magicgui\widgets\_bases\value_widget.py", line 43, in __init__
    super().__init__(**kwargs)
  File "C:\Users\qi2lab\miniconda3\envs\napari-test\lib\site-packages\magicgui\widgets\_bases\widget.py", line 97, in __init__
    self._post_init()
  File "C:\Users\qi2lab\miniconda3\envs\napari-test\lib\site-packages\magicgui\widgets\_bases\categorical_widget.py", line 30, in _post_init
    self.parent_changed.connect(self.reset_choices)
  File "C:\Users\qi2lab\miniconda3\envs\napari-test\lib\site-packages\magicgui\events.py", line 115, in __get__
    d = self._signal_instances.setdefault(self, weakref.WeakKeyDictionary())
  File "psygnal\_signal.py", line 131, in psygnal._signal.Signal.__getattr__
AttributeError: 'Signal' object has no attribute '_signal_instances'

I see there were some magicgui API changes recently, but it didn’t look like I needed to change anything to get this demo to run. Any ideas on how to go about troubleshooting this? First thought was the environment, but this occurs on two different computers with clean environments and clean Napari installs.

Edit: also, I can run Napari normally through Python on both machines. This error only happens when using magicgui.

Thanks!

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
tlambert03commented, Nov 8, 2021

ah, thanks! This actually is caused by the v0.2.0 update of psygnal which included https://github.com/tlambert03/psygnal/pull/28 that removed that attribute. I forgot that magicgui was using that private attribute in its deprecation-strategy file. I’ll push a fix and cut a new release today. Thanks!

1reaction
dpshepherdcommented, Nov 8, 2021

Still using pycromanager, migrating away from that is more than highly distractable PI brain can handle.

eh, that’s low priority 😃 stick with what works until a rainy day!

Or until I can sucker a new group member in with “see, it can’t be that bad. I did the first try at it”

Read more comments on GitHub >

github_iconTop Results From Across the Web

Signal app down? Current outages and problems.
Real-time outages and problems for the Signal app. Can't send messages? No server connection? Here you see what is going on.
Read more >
Troubleshoot receiving messages - Signal Support
Signal uses your phone's internet connection for all private communication. The most common reasons why you can't receive messages when...
Read more >
Signal issues / no service troubleshooting | T-Mobile Support
Troubleshoot no signal or "no service" errors · Registered to T-Mobile network, but no signal: The problem is likely low or no coverage....
Read more >
Signal (@signalapp) / Twitter
Signal is an end-to-end encrypted messaging app. ... national, and world issues as well as in-depth interviews with leading figures in politics, science, ......
Read more >
Issues · signalapp/Signal-Android - GitHub
A private messenger for Android. Contribute to signalapp/Signal-Android development by creating an account on GitHub.
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