jupyter-widgets-contrib / ipycanvas

Interactive Canvas in Jupyter
https://ipycanvas.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
693 stars 64 forks source link

Uncaught exception with ipycanvas 0.8.1 #169

Closed tom1milman closed 3 years ago

tom1milman commented 3 years ago

I've been using ipycanvas 0.5.1, and yesterday decided to update to 0.8.1. I had everything working fine with the 0.5.1. Now I get an uncaught exception when trying to work with ipycanvas.

Here's an example (from the docs) that I try to run when getting the error:

from ipycanvas import Canvas
canvas = Canvas(width=200, height=200)
canvas.fill_rect(25, 25, 100, 100)
canvas.clear_rect(45, 45, 60, 60)
canvas.stroke_rect(50, 50, 50, 50)
canvas

And that's the error I get:

Uncaught (in promise) TypeError: this.ctx[e] is not a function
    at c.executeCommand (widget.ts:290)
    at c.<anonymous> (widget.ts:147)
    at Generator.next (<anonymous>)
    at index.js?v=20201229132724:1
    at new Promise (<anonymous>)
    at s (index.js?v=20201229132724:1)
    at c.processCommand (index.js?v=20201229132724:1)
    at c.<anonymous> (widget.ts:90)
    at Generator.next (<anonymous>)
    at index.js?v=20201229132724:1

image

widgets.ts: image

packages: ipycanvas: 0.8.1 ipywidgets: 7.6.2 Pillow: 8.0.1 numpy: 1.19.4 orjson: 3.4.6

Any ideas what could cause it?

stonebig commented 3 years ago

It works for me, on a fresh install with Jupyterlab-3.0, and also with Jupyter Notebook-6.1.6. It's possible that the whole "upgrade" thing from "Jupyter-2" days to "Jupyter-3" is not fully ironed out yet.

image

martinRenou commented 3 years ago

It's a bit weird that it fails that way, not sure what's happening here

on a fresh install with Jupyterlab-3.0

Indeed I would recommend a fresh environment install. If that's not an option, could you please tell me if you're using jupyter Notebook or JupyterLab, also can you show the output of the following commands?

jupyter nbextension list
jupyter labextension list
tom1milman commented 3 years ago

We found what was causing it. @stonebig @martinRenou thank you for your help!

Here's the report: Problem: After upgrading ipycanvas from 0.5.1 to 0.8.1, user received strange javascript errors with basic usage.

Reason: Jupyterhub was still serving old JS assets (in /usr/local/share/jupyter) from the 0.5.1 package, despite using the 0.8.1 python code.

Fix: Add a JUPYTER_PATH environment variable to the hub pointing to /opt/lv/share/jupyter. This forces Jupyter to first search that directory for assets.