2

I am trying to run a jupyter notebook in a virtualenv. But when starting it and creating a simple ipywidgets example I get the following error:

Widget Javascript not detected.  It may not be installed properly. Did you enable the widgetsnbextension? If not, then run "jupyter nbextension enable --py --sys-prefix widgetsnbextension"

The example code is here:

from ipywidgets import Button, HBox
from ipywidgets import *

button = Button()
button.description = "Test"
display(button)

I have run the following commands on the terminal:

jupyter nbextension enable --py widgetsnbextension
jupyter nbextension enable --py --sys-prefix widgetsnbextension

and I have restarted the notebook anew, and also saw the similar questions here and here, but I still get the same error.

  • python 2.7.12
  • ipywidgets 5.2.2
  • firefox 56.0
  • ubuntu 16.04.3

I need to keep the ipywidgets version in order to test something.

Alex
  • 41,580
  • 88
  • 260
  • 469

2 Answers2

0

I found the solution:

Make sure to remove anything that could be related to anything with jupyter, notebook, ipywidgets from the system configuration, and reinstall everything in your virtualenv. Then run this enable command, start the notebook and it should work...

Alex
  • 41,580
  • 88
  • 260
  • 469
0
sudo pip install ipywidgets --upgrade

helped me

  • 3
    While this code may answer the question, providing additional context regarding how and/or why it solves the problem would improve the answer's long-term value. You can find more information on how to write good answers in the help center: https://stackoverflow.com/help/how-to-answer . Good luck – nima Oct 16 '21 at 12:49