ipywidgets
ipywidgets copied to clipboard
Error running custom anywidget with shinywidget — "RuntimeError: module 'ipykernel' has no attribute 'version_info'"
trafficstars
I a tryin to run a custom anywidget using shinywidgets and get an error when that seems to arise from a broken shim around a missing ipykernelpackage:
Error starting app!
Traceback (most recent call last):
File "/lib/python3.12/site-packages/traitlets/traitlets.py", line 632, in get
value = obj._trait_values[self.name]
~~~~~~~~~~~~~~~~~^^^^^^^^^^^
KeyError: 'layout'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/lib/python3.12/site-packages/ipywidgets/widgets/widget.py", line 615, in get_state
value = to_json(getattr(self, k), self)
^^^^^^^^^^^^^^^^
File "/lib/python3.12/site-packages/traitlets/traitlets.py", line 687, in __get__
return t.cast(G, self.get(obj, cls)) # the G should encode the Optional
^^^^^^^^^^^^^^^^^^
File "/lib/python3.12/site-packages/traitlets/traitlets.py", line 635, in get
default = obj.trait_defaults(self.name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/lib/python3.12/site-packages/traitlets/traitlets.py", line 1897, in trait_defaults
return t.cast(Sentinel, self._get_trait_default_generator(names[0])(self))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/lib/python3.12/site-packages/traitlets/traitlets.py", line 602, in default
return t.cast(G, self.make_dynamic_default())
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/lib/python3.12/site-packages/ipywidgets/widgets/trait_types.py", line 409, in make_dynamic_default
return self.klass(*(self.default_args or ()),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/lib/python3.12/site-packages/ipywidgets/widgets/widget_layout.py", line 86, in __init__
super().__init__(**kwargs)
File "/lib/python3.12/site-packages/ipywidgets/widgets/widget.py", line 506, in __init__
self.open()
File "/lib/python3.12/site-packages/ipywidgets/widgets/widget.py", line 535, in open
self.comm = comm.create_comm(**args)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/lib/python3.12/site-packages/ipywidgets/comm.py", line 28, in create_comm
if requires_ipykernel_shim():
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/lib/python3.12/site-packages/ipywidgets/comm.py", line 11, in requires_ipykernel_shim
version = ipykernel.version_info
^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'ipykernel' has no attribute 'version_info'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<exec>", line 393, in _start_app
File "<exec>", line 366, in __init__
File "/lib/python3.12/site-packages/shiny/express/_run.py", line 62, in wrap_express_app
app_module = importlib.import_module(package_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/lib/python312.zip/importlib/__init__.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
File "/lib/python3.12/site-packages/shiny/express/_run.py", line 102, in exec_module
module.app = create_express_app( # pyright: ignore[reportAttributeAccessIssue]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/lib/python3.12/site-packages/shiny/express/_run.py", line 132, in create_express_app
app_ui = run_express(file, package_name).tagify()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/lib/python3.12/site-packages/shiny/express/_run.py", line 255, in run_express
raise RuntimeError(e) from e
RuntimeError: module 'ipykernel' has no attribute 'version_info'
I'm not sure if this relates to the previously fixed https://github.com/jupyter-widgets/ipywidgets/issues/3819 ?