Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ipywidgets do not work properly #2553

Open
alex4200 opened this issue Sep 6, 2019 · 22 comments

Comments

@alex4200
Copy link

commented Sep 6, 2019

Using ipywidgets 7.5.1 I have tried to enable this extension:

!jupyter nbextension enable --py widgetsnbextension

and then to use the following example, after restarting the kernel and reloading the page:

from ipywidgets import Text
Text("Hello")

But the output is always the following:

Text(value='Hello')

Screenshot 2019-09-06 at 16 24 29

How can this be fixed/debugged?

@diallobakary4

This comment has been minimized.

Copy link

commented Sep 7, 2019

I am also experiencing the same thing in jupyterlab. Not sure it is related, I am running the notebook on a server and uses ssh tunnelling to access it. The classic notebook works fine on the server. I have a similar local installation which is working fine which jupyterlab.

@jasongrout

This comment has been minimized.

Copy link
Member

commented Sep 7, 2019

@alex4200 - please follow the installation instructions for JupyterLab: https://ipywidgets.readthedocs.io/en/latest/user_install.html#installing-the-jupyterlab-extension

Basically, you need to do:

jupyter labextension install @jupyter-widgets/jupyterlab-manager

and have nodejs installed for jupyterlab to rebuild itself.

@jasongrout jasongrout added this to the Reference milestone Sep 7, 2019
@alex4200

This comment has been minimized.

Copy link
Author

commented Sep 9, 2019

@jasongrout Thanks for your reply, but I am not the admin of the system where the notebooks are set up. I am looking more for a way to debug this issue, as the system/circumstances are way more complicated.

First, there is a central instance of there this is set up. I assume it is set up the same for each user. Each user has a container running in a VM, in which the notebook kernel is running. Each user can have a different set of environment (i.e. different pieces of software installed by pip).

Now it happens that the ipywidget example works for one user, but not for the other user. I want to find the specific reason why the ipywidget example is working for the one user, but nor for the other user. What kind of debugging can I do for the user it is not working for?

Also, as it happens, the above example now works as expected, without any apparent change I made to the system/environment.

@joshwarren

This comment has been minimized.

Copy link

commented Sep 25, 2019

I'm also having the same issue. It happens with the sidecar extension too - I think I've installed and enabled extensions correctly:

jwarren:~$ jupyter labextension list
   app dir: c:\users\jwarren\appdata\local\continuum\anaconda3\share\jupyter\lab
        @ijmbarr/jupyterlab_spellchecker v0.1.5 enabled  ok
        @jupyter-widgets/jupyterlab-manager v1.0.2 enabled  ok
        @jupyter-widgets/jupyterlab-sidecar v0.3.0 enabled  ok
        jupyter-leaflet v0.11.2 enabled  ok
JupyterLab v1.0.0
Known labextensions:

jwarren:~$ pip show ipywidgets
Name: ipywidgets
Version: 7.5.1
Summary: IPython HTML widgets for Jupyter
Home-page: http://ipython.org
Author: IPython Development Team
Author-email: ipython-dev@scipy.org
License: BSD
Location: c:\users\jwarren\appdata\local\continuum\anaconda3\lib\site-packages
Requires: traitlets, ipykernel, ipython, nbformat, widgetsnbextension
Required-by: jupyter, sidecar, ipyleaflet

jwarren:~$ yarn -v
1.17.3

jwarren:~$ npm -v
6.10.2

jwarren:~$ conda list nodejs
# packages in environment at C:\Users\jwarren\AppData\Local\Continuum\anaconda3:
#
# Name                    Version                   Build  Channel
nodejs                    12.8.1                        0    conda-forge

I've tried running the install commands again, as suggested by @jasongrout. It all works as expected in a classic notebook (like @diallobakary4).

@joshwarren

This comment has been minimized.

Copy link

commented Sep 25, 2019

I think this the same as #2220 and #2361?

@jasongrout's suggestion to run jupyter lab clean before jupyter lab build seems to have worked for me!

@alex4200

This comment has been minimized.

Copy link
Author

commented Sep 25, 2019

@joshwarren As I am not an admin of the jupyter notebook - is there nothing that I can do from inside a running notebook?

Just to be clear: I am using a jupyter notebook on some browser. I do not know where the actual notebook runs, how it was started etc., I am just using a running notebook. Is there a way to fix these ipywidgets? Or do I have to talk to the system administrators?

If it is the latter: What to tell them? Restart jupyter? Restart the container? Restart the kernel? Reinstall the addon? Something else?

@joshwarren

This comment has been minimized.

Copy link

commented Sep 25, 2019

@alex4200 ah I'm afraid my fix was for a similar issue with jupyter lab: it worked fine within a classic notebook for me. Sorry - I'm not much help.

@jasongrout

This comment has been minimized.

Copy link
Member

commented Sep 25, 2019

@alex4200 - just to be clear, you are talking about using a notebook inside JupyterLab, right?

As for debugging, probably the most helpful would be the javascript console errors.

Also, you can go to the extension manager (enabled from the Setting menu), and see if the @jupyter-widgets/jupyterlab-manager extension is installed/enabled.

@alex4200

This comment has been minimized.

Copy link
Author

commented Sep 25, 2019

@jasongrout As far as I know the notebook is running inside JupyterHub (server version 5.0.0). And here I do not see any option 'extension manager'.

The UI looks as follows (and now the extension works fine, by chance. Some next time it will not work fine again):

Selection_819

I can check the console and will list it here when it stop working again.

@jasongrout

This comment has been minimized.

Copy link
Member

commented Sep 25, 2019

Ah, somehow I missed that this was in the classic Notebook and not in JupyterLab.

Still, any javascript errors in the browser js console likely will reveal something about what the problem is.

@alex4200

This comment has been minimized.

Copy link
Author

commented Oct 10, 2019

Now I have a different output:

Failed to display Jupyter Widget of type Text.

If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean that the widgets JavaScript is still loading. If this message persists, it likely means that the widgets JavaScript library is either not installed or not enabled. See the Jupyter Widgets Documentation for setup instructions.

If you're reading this message in another frontend (for example, a static rendering on GitHub or NBViewer), it may mean that your frontend doesn't currently support widgets.

For me ipywidgets is not useable most of the time.

@jasongrout

This comment has been minimized.

Copy link
Member

commented Oct 10, 2019

This message is from an old version of ipywidgets. Likely import ipywidgets; ipywidgets.__version__ is not 7.5.1. In your original post, you said you had ipywidgets 7.5.1 installed, so tracking down why this old version is showing up may be useful.

@alex4200

This comment has been minimized.

Copy link
Author

commented Oct 10, 2019

Version is 7.0.5 currently.

Console gives error message: "Couldn't create a model."

@jasongrout

This comment has been minimized.

Copy link
Member

commented Oct 10, 2019

It seems that there is something wrong in your installation, or perhaps a mismatch between the version in the python kernel and the version in the javascript. I would suggest uninstalling and reinstalling widgets (preferably installing the latest version) as the simplest way to fix whatever is wrong.

@alex4200

This comment has been minimized.

Copy link
Author

commented Oct 10, 2019

Is there any way to fix that without 'uninstalling and reinstalling widgets', as that would involved other people? I do not have the user rights to 'uninstall and reinstall' widgets, and solving the problem by my own would help much!

@jasongrout

This comment has been minimized.

Copy link
Member

commented Oct 10, 2019

ipywidgets 7.0.5 was released about 2 years ago, it may be good to upgrade anyway. And again, likely this is a configuration or version mismatch issue (or perhaps a bug fixed in the last two years?). It seems that things have evolved since you first posted the issue (where you had ipywidgets 7.5.1), and it's difficult to understand how things are set up right now and thus how to help.

If you have to diagnose your current setup, some information would help:

  • What version of the notebook are you using?
  • What version of python are you using?
  • What version of ipywidgets is installed on the python side (I think you answered that now it is 7.0.5? How was it 7.5.1 before? Are there two versions installed on top of each other somehow?)
  • What version of widgetsnbextension is installed? Are there possibly multiple copies of the javascript installed?
  • What is the code you are running that gives the error? Is there a sequence of steps from opening a fresh new notebook that can reproduce the problem?
@alex4200

This comment has been minimized.

Copy link
Author

commented Oct 10, 2019

  • The version of the notebook server is 5.0
  • Python is Python 3.6.7
  • Version of ipywidgets is currently 7.0.5
  • widgetsnbextension 3.0.8 (there could be multiple copies of the javascript been installed)
  • The code to get the error: See in the actual description above.

The general problem is that there are different notebooks that might install a different version of ipywidgets/widgetsnbextension, along of different version of other countless packages. So I run one notebook which installs some set A, then another notebook installs set B, notebook 3 installs set C, and of course there can be a LOT of version mismatch. But I am interested in the ones for ipywidgets only.

@jasongrout

This comment has been minimized.

Copy link
Member

commented Oct 10, 2019

The code to get the error: See in the actual description above.

So every time you run

from ipywidgets import Text
Text("Hello")

in a fresh notebook kernel, you get

Failed to display Jupyter Widget of type Text.

If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean that the widgets JavaScript is still loading. If this message persists, it likely means that the widgets JavaScript library is either not installed or not enabled. See the Jupyter Widgets Documentation for setup instructions.

If you're reading this message in another frontend (for example, a static rendering on GitHub or NBViewer), it may mean that your frontend doesn't currently support widgets.

in the output and

Console gives error message: "Couldn't create a model."

as a corresponding message in the js console?

And just to be clear, this notebook has a cell at the top that says !jupyter nbextension enable --py widgetsnbextension and that's how the js was installed?

@alex4200

This comment has been minimized.

Copy link
Author

commented Oct 11, 2019

Yes I guess you are correct.

  1. Restart the kernel
  2. Execute !jupyter nbextension enable --py widgetsnbextension
  3. Execute from ipywidgets import Text Text("Hello")

But how the js was installed - I have no idea. I am not the admin of the jupyter framework, I am just using it.

@jasongrout

This comment has been minimized.

Copy link
Member

commented Oct 11, 2019

Can you refresh your browser after installing the widgetsnbextension package to make sure you are picking up the javascript?

If that doesn't work - I'm out of ideas now. It sound like there are a lot of variables and moving pieces, and it would probably be best to talk to your system administrators.

@alex4200

This comment has been minimized.

Copy link
Author

commented Oct 11, 2019

Yes I can try to reload the pages.

And yes there are a lot of moving pieces. I just wanted to find that piece that is moving out, to fix that. But I guess this is too complicated to do?

@alex4200

This comment has been minimized.

Copy link
Author

commented Oct 11, 2019

I asked the admins to 'reset' the container the jupyter notebook is running in (back to basic configuration). After a reload of the page the ipywidget works again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.