mwcraig / ipyevents

A custom widget for returning mouse and keyboard events to Python. Documentation:
https://ipyevents.readthedocs.io/en/latest/index.html
BSD 3-Clause "New" or "Revised" License
115 stars 27 forks source link

package.json update needed for JupyterLab 3 compatibility, maybe #65

Closed pkgw closed 3 years ago

pkgw commented 3 years ago

As per this Jupyter Discourse thread, I have been running into some funky issues with ipyevents on JupyterLab 3.

I don't feel that I understand this well at all, but I think what might be going on is simply that this project's package.json needs to be updated to indicate that it is also compatible with the 4.x series of @jupyter-widgets/base. @mwcraig if you agree with this diagnosis I'm happy to prepare a PR, but I wanted to post an issue first since you're a lot more familiar with this stuff than I am.

CC @matthewturk who expressed interest in this topic on Twitter.

janfreyberg commented 3 years ago

Just chiming in to say that this is probably the issue I just described in #56 as well (apologies for the duplication). Copying my comment over:

Hi, I think I am experiencing this issue even when I have the latest version of the npm / pypi packages installed.

I'm using jupyterlab 3, and have the latest ipyevents:

Environment

``` $ pip show ipyevents jupyterlab ipywidgets Name: ipyevents Version: 0.8.1 Summary: A custom widget for returning mouse and keyboard events to Python Home-page: https://github.com/mwcraig/ipyevents Author: Matt Craig Author-email: mattwcraig@gmail.com License: BSD 3-clause Location: /Users/jan/github/ipyannotations/.venv/lib/python3.8/site-packages Requires: ipywidgets Required-by: --- Name: jupyterlab Version: 3.0.3 Summary: The JupyterLab server extension. Home-page: http://jupyter.org Author: Jupyter Development Team Author-email: jupyter@googlegroups.com License: BSD Location: /Users/jan/github/ipyannotations/.venv/lib/python3.8/site-packages Requires: jinja2, jupyter-core, packaging, tornado, jupyter-server, jupyterlab-server, ipython, nbclassic Required-by: --- Name: ipywidgets Version: 7.6.3 Summary: IPython HTML widgets for Jupyter Home-page: http://ipython.org Author: IPython Development Team Author-email: ipython-dev@scipy.org License: BSD Location: /Users/jan/github/ipyannotations/.venv/lib/python3.8/site-packages Requires: traitlets, ipykernel, widgetsnbextension, ipython, nbformat, jupyterlab-widgets Required-by: ipyevents, ipycanvas, ipyannotations ```

They seem to be installed, although there's something different about ipyevents:

$ jupyter labextension list

JupyterLab v3.0.3
/Users/jan/github/ipyannotations/.venv/share/jupyter/labextensions
        ipycanvas v0.8.1 enabled OK
        ipyannotations v0.1.0 enabled OK
        @jupyter-widgets/jupyterlab-manager v3.0.0 enabled OK (python, jupyterlab_widgets)

Other labextensions (built into JupyterLab)
   app dir: /Users/jan/github/ipyannotations/.venv/share/jupyter/lab
        ipyevents v1.8.1 enabled OK

The following error occurs in the javascript console when trying to run an example:

from ipywidgets import Label, HTML, HBox, Image, VBox, Box, HBox
from ipyevents import Event 
from IPython.display import display

l = Label('Click or type on me!')
l.layout.border = '2px solid red'

h = HTML('Event info')
d = Event(source=l, watched_events=['click', 'keydown', 'mouseenter'])

def handle_event(event):
    lines = ['{}: {}'.format(k, v) for k, v in event.items()]
    content = '<br>'.join(lines)
    h.value = content

d.on_dom_event(handle_event)

display(l, h)
Plugin 'ipyevents' failed to activate.
(anonymous) @ index.es6.js:282
index.es6.js:283 Error: No provider for: jupyter.extensions.jupyterWidgetRegistry.
    at W.e.resolveRequiredService (index.es6.js:197)
    at index.es6.js:155
    at Array.map (<anonymous>)
    at W.e.activatePlugin (index.es6.js:155)
    at index.es6.js:281
    at Array.map (<anonymous>)
    at W.e.start (index.es6.js:280)
    at Y (index.out.js:597)
(anonymous) @ index.es6.js:283
index.es6.js:282 Plugin 'ipycanvas:plugin' failed to activate.
(anonymous) @ index.es6.js:282
index.es6.js:283 Error: No provider for: jupyter.extensions.jupyterWidgetRegistry.
    at W.e.resolveRequiredService (index.es6.js:197)
    at index.es6.js:155
    at Array.map (<anonymous>)
    at W.e.activatePlugin (index.es6.js:155)
    at index.es6.js:281
    at Array.map (<anonymous>)
    at W.e.start (index.es6.js:280)
    at Y (index.out.js:597)
(anonymous) @ index.es6.js:283
index.es6.js:282 Plugin 'ipyannotations' failed to activate.
(anonymous) @ index.es6.js:282
index.es6.js:283 Error: No provider for: jupyter.extensions.jupyterWidgetRegistry.
    at W.e.resolveRequiredService (index.es6.js:197)
    at index.es6.js:155
    at Array.map (<anonymous>)
    at W.e.activatePlugin (index.es6.js:155)
    at index.es6.js:281
    at Array.map (<anonymous>)
    at W.e.start (index.es6.js:280)
    at Y (index.out.js:597)
(anonymous) @ index.es6.js:283
settingregistry.js:371 Ignored setting registry preload errors. Array(1)
(anonymous) @ settingregistry.js:371
settingregistry.js:371 Ignored setting registry preload errors. Array(1)
(anonymous) @ settingregistry.js:371
manager-base.js:274 Could not instantiate widget
(anonymous) @ manager-base.js:274
utils.js:119 Error: Could not create a model.
    at n (utils.js:119)
    at async _handleCommOpen (523.fa256ee012d38a89b65a.js:1)
    at async C._handleCommOpen (default.js:1039)
    at async C._handleMessage (default.js:1213)
n @ utils.js:119
default.js:1046 Exception opening new comm
_handleCommOpen @ default.js:1046
2523.fa256ee012d38a89b65a.js:1 Uncaught (in promise) Error: Module ipyevents, semver range 1.8.1 is not registered as a widget module
    at x.loadClass (523.fa256ee012d38a89b65a.js:1)
    at x.<anonymous> (manager-base.js:264)
    at l (manager-base.js:45)
    at Object.next (manager-base.js:26)
    at manager-base.js:20
    at new Promise (<anonymous>)
    at A (manager-base.js:16)
    at x.e._make_model (manager-base.js:258)
    at x.<anonymous> (manager-base.js:247)
    at l (manager-base.js:45)
mwcraig commented 3 years ago

The problem is the compatibility issue. WIll do a quick release tonight or early tomorrow AM

pkgw commented 3 years ago

Thanks!

mwcraig commented 3 years ago

I just pushed a new version to pypi (0.8.2) and npm (1.8.2). As soon as the conda-forge bot opens a PR for the update I'll merge the conda-forge release too.

Please try out the new release and let me know if it works for you.

janfreyberg commented 3 years ago

Works for me in Jupyterlab 3. Thank you very much!

pkgw commented 3 years ago

Thanks! The conda-forge PR is now up and looks sensible enough.

xref: https://github.com/conda-forge/ipyevents-feedstock/pull/22