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
112 stars 27 forks source link

Running ipyevents in Jupyter lab 2 #56

Closed fschiffers closed 3 years ago

fschiffers commented 4 years ago

Hello, I'm trying to ipyevents in Jupyter Lab 2

When I try to do the example I get the following error in the javascript console: Module ipyevents, semver range 1.8.0 is not registered as a widget module

Does anyone know what I could do to make it work?

Best, Florian

mwcraig commented 4 years ago

Thanks for reporting this @fschiffers. What output do you get from jupyter labextension list?

fschiffers commented 4 years ago

Hi, thanks for the quick response. Please let me know if you need more

(pytorch3d) ➜ ~ jupyter labextension list JupyterLab v2.1.4 Known labextensions: app dir: /opt/anaconda/envs/pytorch3d/share/jupyter/lab @jupyter-widgets/jupyterlab-manager v2.0.0 enabled OK @lckr/jupyterlab_variableinspector v0.5.1 enabled OK bqplot v0.5.17 enabled OK ipycanvas v0.5.0 enabled OK ipyevents v1.8.0 enabled OK ipyvolume v0.6.0-alpha.5 enabled OK jupyter-matplotlib v0.7.3 enabled OK jupyter-threejs v2.2.0 enabled OK jupyter-webrtc v0.5.0 enabled OK jupyterlab-datawidgets v6.3.0 enabled OK

mwcraig commented 4 years ago

What version of ipyevents do you have installed?

fschiffers commented 4 years ago

I am using ipyevents-0.8.0

I've installed through pip using the following commmands:

To install use pip:

$ pip install ipyevents $ jupyter nbextension enable --py --sys-prefix ipyevents

To install with JupyterLab (whether you installed with conda or pip):

$ jupyter labextension install @jupyter-widgets/jupyterlab-manager ipyevents

mwcraig commented 4 years ago

I'm having some trouble reproducing this (which is not unusual)...a few things to try/check:

fschiffers commented 4 years ago

Hi! Thanks Matt

  1. I'm running a python kernel (pytorch3d) in the anaconda environment (pytorch3d). Inside PyTorch3D I've installed JupyterLab
  2. With clear cache and reload you're referring to "Restart the kernel" ? I've restarted the complete Jupyter Lab several times after installation of ipwidgets
  3. Jupyter Lab and Ipyevents should be installed in the same environment
  4. Output of "jupyter lab paths"

(pytorch3d) anaconda@cplrtx:~$ jupyter lab paths Application directory: /opt/anaconda/envs/pytorch3d/share/jupyter/lab User Settings directory: /home/anaconda/.jupyter/lab/user-settings Workspaces directory: /home/anaconda/.jupyter/lab/workspaces

I have anaconda installed for multiple users to used in /opt/anaconda. Inside there I have the PyTorch3D environment, so every user just logs into his account, and without any installation one can use "conda activate pytorch3D". I've had a few problems with this configuration before.

darcyalcantara commented 4 years ago

I am having trouble here too. Ipyevents not working.

Running "jupyter labextension list", I get:

JupyterLab v2.2.6 Known labextensions: app dir: .../venv/share/jupyter/lab @jupyter-widgets/jupyterlab-manager v2.0.0 enabled OK ipyevents v1.8.0 enabled OK

darcyalcantara commented 4 years ago

I tried to clear cache of the browser, then this message appeared when I started the server again:

image

After building is done, nothing changed.

darcyalcantara commented 4 years ago

Updating: in Jupyter Notebook it's work fine! The problem is only on Jupiter Lab. Thank you, in advance.

fschiffers commented 4 years ago

Yes, Jupyter Notebook often has way less problems with extensions (such as ipywidgets) than Jupyter Lab. Especially since Jupyter Lab 2.0 I've been running into a lot of compatibility issues.

Hopefully, this can be solved since ipyevents seems to be a really cool extension !

mwcraig commented 4 years ago

The good news is that Jupyter Lab 3 is focused on making the extension system as painless as it is with notebook. I'll try to take another look later today.

fschiffers commented 4 years ago

Please let us know if there's anything we can assist you with by providing more information for debugging or reproducing our errors.

agoose77 commented 4 years ago

Just a note - I've had problems reproducing bug reports with my extensions. I found building a Docker image from a Dockerfile very helpful in avoiding caching issues.

itssimon commented 3 years ago

I'm having the same issue in JupyterLab 2.2.8 ☹️ Below is my jupyter labextension list output:

JupyterLab v2.2.8
Known labextensions:
   app dir: /opt/conda/share/jupyter/lab
        @aquirdturtle/collapsible_headings v2.2.0  enabled  OK
        @jupyter-widgets/jupyterlab-manager v2.0.0  enabled  OK
        @jupyterlab/git v0.20.0  enabled  OK
        @jupyterlab/server-proxy v2.1.1  enabled  OK
        @jupyterlab/toc v4.0.0  enabled  OK
        @oriolmirosa/jupyterlab_materialdarker v0.5.0  enabled  OK
        @ryantam626/jupyterlab_code_formatter v1.3.6  enabled  OK
        ipyevents v1.8.0  enabled  OK
        ipyselect2 v0.2.1  enabled  OK
        jupyterlab-execute-time v1.0.0  enabled  OK
        jupyterlab-jupytext v1.2.1  enabled  OK
        nbdime-jupyterlab v2.0.1  enabled  OK
        qgrid2 v1.1.3  enabled  OK

Anything we can do to help track this down?

mwcraig commented 3 years ago

I just did a release because it turns out that there was a serious error in the npm package for 0.8.0/1.8.0.

If you are running into the issues here can you try upgrading and report back whether it works or not?

The new version is 0.8.1 on pypi and 1.8.1 on npm (so 1.8.1 is what you should see in labextension list after update). It may be a few minutes until the conda-forge package is available for installation.

itssimon commented 3 years ago

After upgrading to 0.8.1/1.8.1 ipyevents works fine in JupyterLab again. Thanks heaps!

mwcraig commented 3 years ago

@fschiffers @daneto82 -- can you please give the new version a try when you get a chance and report back whether the issue is now fixed for you?

mwcraig commented 3 years ago

I'm going to close this for now, but feel free to reopen @fschiffers or @daneto82 if it isn't working for you.

janfreyberg commented 3 years ago

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

Thanks for reporting @janfreyberg -- I'm hoping this is just #65