Help on jupyter lab --no-browser where widgets, ipyturtle do not render

Hi there; I am running jupyter lab on a cloud VM using --no-browser and connecting my browser via ssh tunnel. I would really appreciate either help here (details below) or a pointer to some documentation. I have done a lot of looking but can find nothing that gives me a way forward.

In detail: On an AWS EC2 instance with Anaconda installed I start with (jupyter lab --no-browser --port=8889) & then set up the ssh tunnel, connect my browser and everything looks ok. For example matplotlib makes charts. However after getting the OK response to jupyter nbextension enable -py widgetsnbextension I try to verify that the extension is installed with jupyter labextension list and that returns No installed extensions. I have done the install and it runs fine; so ought to be current.

  • jupyter notebook --version gives 6.0.3
  • jupyter lab --version gives 2.1.5
  • node --version gives v6.13.1

In a notebook I can run the following cell and get text output 10 but no slider.

from __future__ import print_function
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgets

def f(x): return x

interact(f, x=10);

Similarly with an install of ipyturtle it runs fine but no render.

thanks -rob

If you go to Help > Launch Classic Notebook and try running the things you say aren’t working, do they work in the classic notebook interface? And if by chance it works there, do you absolutely need it to work in Jupyter Lab? I ask because there is still some flux going on with extensions and JupyterLab. And I don’t know what instructions or documentation you are following, but it looks like you are dealing with installing extensions in the classic notebook interface.

Normally, I’d point you to the Binder example that includes the widgets extension installed and enabled for JupyterLab to give you an idea of how to get it working. But even there, at the present time it isn’t building right with version 2.2 of JupyterLab, as discussed here and here. (For the record, normally I’d suggest you go here and press the launch binder badge next to the text ‘(Jupyter Lab)’. Then when you saw it was working you could try applying the commands in postBuild dealing with extensions and JupyterLab to your situation.)
I don’t have any additional information of that sort for ipyturtle. However, it is probably similar where you are better off at this time trying it in the classic interface first.

Although I don’t suspect that is the issue, you raise the issue of your install being current; however, your version of JupyterLab isn’t totally current. 2.2 has been available a while now. It looks like from here if you installed recently using conda you should see 2.2.9. Did you use a recent version of Ubuntu when you set up the AMI on your EC2 instance?

Thanks Wayne;

EC2: Ubuntu was whatever the default was a week ago and I’ve run sudo apt upgrade a couple times. Obviously if Ubuntu is an issue I can pick some other flavor of Linux as a start image.

To the crux:

Classic mode almost works. The slider appears and is adjustable with changing readout; but it also creates an infinite tailspin error (I paste this below) that does not halt even when I stop the kernel. A re-start of the kernel does halt it. And ipyturtle is still not producing any output. I do initiate the nbextension with jupyter nbextension enable --py --sys-prefix ipyturtle but to no avail.

My preference is Jupyter Lab but of course I can do the Classic workaround if I can get that working without the error until such time. I notice you did not flag my node version so that is a relief as I have not been able to make progress with perhaps updating it. r

--- Logging error ---
Traceback (most recent call last):
  File "/home/ubuntu/anaconda3/lib/python3.8/site-packages/ipykernel/comm/manager.py", line 67, in get_comm
    return self.comms[comm_id]
KeyError: '3759d9c5d38c4f0c8c14c5305b71ae8e'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ubuntu/anaconda3/lib/python3.8/logging/__init__.py", line 1085, in emit
    self.flush()
  File "/home/ubuntu/anaconda3/lib/python3.8/logging/__init__.py", line 1065, in flush
    self.stream.flush()
OSError: [Errno 5] Input/output error
Call stack:
  File "/home/ubuntu/anaconda3/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/ubuntu/anaconda3/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/ubuntu/anaconda3/lib/python3.8/site-packages/ipykernel_launcher.py", line 16, in <module>
    app.launch_new_instance()
  File "/home/ubuntu/anaconda3/lib/python3.8/site-packages/traitlets/config/application.py", line 664, in launch_instance
    app.start()
  File "/home/ubuntu/anaconda3/lib/python3.8/site-packages/ipykernel/kernelapp.py", line 612, in start
    self.io_loop.start()
  File "/home/ubuntu/anaconda3/lib/python3.8/site-packages/tornado/platform/asyncio.py", line 149, in start
    self.asyncio_loop.run_forever()
  File "/home/ubuntu/anaconda3/lib/python3.8/asyncio/base_events.py", line 570, in run_forever
    self._run_once()
  File "/home/ubuntu/anaconda3/lib/python3.8/asyncio/base_events.py", line 1859, in _run_once
    handle._run()
  File "/home/ubuntu/anaconda3/lib/python3.8/asyncio/events.py", line 81, in _run
    self._context.run(self._callback, *self._args)
  File "/home/ubuntu/anaconda3/lib/python3.8/site-packages/tornado/ioloop.py", line 690, in <lambda>
    lambda f: self._run_callback(functools.partial(callback, future))
  File "/home/ubuntu/anaconda3/lib/python3.8/site-packages/tornado/ioloop.py", line 743, in _run_callback
    ret = callback()
  File "/home/ubuntu/anaconda3/lib/python3.8/site-packages/tornado/gen.py", line 787, in inner
    self.run()
  File "/home/ubuntu/anaconda3/lib/python3.8/site-packages/tornado/gen.py", line 748, in run
    yielded = self.gen.send(value)
  File "/home/ubuntu/anaconda3/lib/python3.8/site-packages/ipykernel/kernelbase.py", line 365, in process_one
    yield gen.maybe_future(dispatch(*args))
  File "/home/ubuntu/anaconda3/lib/python3.8/site-packages/tornado/gen.py", line 209, in wrapper
    yielded = next(result)
  File "/home/ubuntu/anaconda3/lib/python3.8/site-packages/ipykernel/kernelbase.py", line 268, in dispatch_shell
    yield gen.maybe_future(handler(stream, idents, msg))
  File "/home/ubuntu/anaconda3/lib/python3.8/site-packages/ipykernel/comm/manager.py", line 106, in comm_msg
    comm = self.get_comm(comm_id)
  File "/home/ubuntu/anaconda3/lib/python3.8/site-packages/ipykernel/comm/manager.py", line 69, in get_comm
    self.log.warning("No such comm: %s", comm_id)
Message: 'No such comm: %s'
Arguments: ('3759d9c5d38c4f0c8c14c5305b71ae8e',)

(repeat ad infinitum)

The question about Ubuntu was just speculation as to why you are getting a slightly older version of Jupyter Lab than Anaconda lists. I was wondering if you were using 16.04 or 18.04 and conda was noting something in it and keeping JupyterLab older based on that. But apparently that wasn’t it. Ubuntu should be fine.

Sadly I haven’t tried setting this up recently, and so I cannot confirm if I see the same thing or not.
Did you try running conda update jupyter and then run things?
Did you try running this:

conda install ipywidgets
conda install widgetsnbextension

And then try enabling and running it in the classic notebook mode?

And if that doesn’t help, try opening a notebook in the classic interface and running the following in it:

%pip install ipywidgets
%pip install widgetsnbextension

Then close the notebook session and run jupyter nbextension enable --py widgetsnbextension in your terminal. Then relaunch your notebook session and see if widgets work in your classic interface then.

Your slider code works fine when run in sessions launched form here.

I have no idea about ipyturtle but maybe if you figure out what finally gets the ipywidgets extension working right in your environment, you can try that approach with ipyturtle.

1 Like

Did you follow the installation instructions ? it looks like you only installed for the classic notebook but not for jupyter lab for which you need to run:

jupyter labextension install @jupyter-widgets/jupyterlab-manager

Also beware that there’s different versions for different jupyter lab versions (see https://github.com/jupyter-widgets/ipywidgets#install). It looks like you have jupyter lab 2.1 so you can make sure you have the right version with:

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

Guillaume

1 Like

Thanks to you both. Some progress: I had to throw it in reverse so my necessary install of nodejs v15 was not masked; so that I can run that jupyter labextension command. Here is a precis of the command sequence:

  • curl -sL https://deb.nodesource.com/setup_15.x | sudo -E bash to get nodejs updated
  • sudo apt-get install -y nodejs to install it; and this worked fine
  • node --version shows the wrong (ancient) version of nodejs shadowing what i just installed
  • which node shows the old nodejs installed within anaconda… let’s uninstall it
  • conda uninstall nodejs … worked… does this reveal the new install?
  • which node produces /usr/bin/node so that looks encouraging
  • node shows voila v15, great
  • jupyter labextension install @jupyter-widgets/jupyterlab-manager@2.0 per Guillaume; this runs fine

Now the widget appears in Jupyter Lab as desired, no errors, Classic Notebook not necessary. turtle is still MIA but I’ll work on this. Let’s call this closed.

This suggests an install guide for people like me with minimal Jupyter context towards diagnostic skills. My documentation at this repo is a contribution to the process fwiw; and I’ll try and reflect this there. Thanks again for the excellent help!

1 Like

Great! Just a few more comments:

  • It’s not clear to me why you need nodejs v15. Do you need it to run something else? Otherwise, it seems much simpler and cleaner to just create an environment where you install everything e.g.:
    conda create -n labwidget_test pip jupyter jupyterlab nodejs ipywidgets
    conda activate labwidget_test
    jupyter labextension install @jupyter-widgets/jupyterlab-manager@2.0
    pip install ipyturtle
    jupyter nbextension enable --py --sys-prefix ipyturtle
    
    WIth that setup, ipywidgets runs without trouble in JupyterLab.
  • ipyturtle is not designed to work in JupyterLab, so you can only run it in the classic notebook
  • I had a look at your documentation. SSH tunnelling is always annoying for end-users. I guess you know that in principle you can just open a port on your VM and access directly to Jupyter via the IP address of your machine?

Guillaume

2 Likes