jupyter-widgets-contrib / ipycanvas

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

No canvas output #82

Closed acejacek closed 4 years ago

acejacek commented 4 years ago

I can't get any output. For example, this piece of code:

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

the only output I'm getting is:

Canvas(height=200, width=200)

I'm running than on MacOS, with brewed Python 3.7 and latest Jupyter. All installed according to the book, without Anaconda. No errors thrown, nothing to debug. All modules present, node v13, all are there waiting. Tested on multiple browsers too (Safari, Chrome, Firefox).

I'm totally clueless. I'm new in the game, so maybe I'm doing a trivial error, but Google can't help me.

martinRenou commented 4 years ago

Thanks for opening an issue.

Otherwise, please provide the output of the following commands:

which jupyter
jupyter nbextension list
jupyter labextension list
acejacek commented 4 years ago

Hi, I reinstalled everything from the scratch (making a deep puge of everything python-related), and now ipycanvas works perfectly. Thanks for all!

martinRenou commented 4 years ago

Happy to hear that it works! Don't hesitate to open other issues if you have any questions.

MiguelCorti commented 4 years ago

Hi! Didn't want to open a new issue as the problem I'm having seems very similar to this one, but I can't seem to solve it :(

I'm using Jupyter Notebook (no JupyterLab) without Anaconda. I'm using python 3.8.2 and installed ipycanvas 0.5.0 using pip. But I'm getting no output from canvas. I'm trying to run the following code from the the ipycanvas docs:

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

The output is blank, but looking at my console (where jupyter server is running) I see the following output:

[W 10:57:08.758 NotebookApp] 404 GET /static/ipycanvas.js?v=20200903105459 (127.0.0.1) 1.01ms referer=http://localhost:8888/notebooks/trab_1.ipynb

And inspecting the browser console I see several errors as well: image I think it may be relevant to note that I'm using WSL with Ubuntu 20.04 as well.

Using ipycanvas on Jupyter Notebook through MyBinder gave me the exact same issue, but I was able to solve it running !jupyter labextension install @jupyter-widgets/jupyterlab-manager ipycanvas

As I don't have jupyter lab installed locally, I don't know what else to do.

Thanks! I can open a new issue if it seems appropiate.

martinRenou commented 4 years ago

Hey!

Can you run the following command in a terminal and show me the output:

jupyter nbextension list
MiguelCorti commented 4 years ago

Sure, sorry for taking long! I missed your comment...

Here is the output: image

martinRenou commented 4 years ago

Try running:

jupyter nbextension install --py --symlink --sys-prefix ipycanvas
jupyter nbextension enable --py --sys-prefix ipycanvas

This should not actually be needed. But it might fix your issue.

MiguelCorti commented 4 years ago

Thanksssssss, that worked! A friend of mine was having the same issue (using only notebook and pycanvas), will pass the knowledge on. Also, I had some problems with permissions when running both these commands, so I actually ran:

jupyter nbextension install --py --symlink --sys-prefix ipycanvas --user
jupyter nbextension enable --py ipycanvas

Added --user on the first command and removed --sys-prefix from the second one.

Everything seems to be working normally now. Thanks a lot!