1

The following code works fine on my local machine/environment:

from ipycanvas import Canvas
canvas = Canvas(width=300, height=300)
display(canvas)

But using jupyterhub installed on VM on GCP it does no longer display the canvas.

What is missing ?

moctarjallo
  • 1,479
  • 1
  • 16
  • 33

1 Answers1

2

ipycanvas is a package which needs to be installed in the same environment as the jupyterlab instance. Additionally, you need to have nodejs installed, and you need to enable the jupyterlab ipycanvas widget.

These are all covered in the ipycanvas installation instructions:

Using conda

conda install -c conda-forge ipycanvas

JupyterLab extension

If you have JupyterLab, you will also need to install the JupyterLab extension. In order to install the JupyterLab extension, you will need npm to be installed. You can easily install npm with conda:

conda install -c conda-forge nodejs

Then you can install the JupyterLab extension:

jupyter labextension install @jupyter-widgets/jupyterlab-manager ipycanvas

Since you mention that you're on jupyterhub, if you're on a cluster and you're not the administrator, it's possible you don't have the permissions to do this. If that's the case, reach out to your cluster administrator - it's possible they don't allow users to enable extensions.

Michael Delgado
  • 13,789
  • 3
  • 29
  • 54
  • It displays after doing all this (with `sudo` commands and after restarting the server..). Should I do the same thing with `ipyevents` too because now this one too is not working. – moctarjallo May 28 '22 at 20:18
  • Yeah you’ll have to install every plug-in that you want on the server – Michael Delgado May 28 '22 at 20:51
  • You're right. I actually did all this locally but completely forgot about it during deployment lol. Thanks! – moctarjallo May 31 '22 at 17:37