Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No module named 'ipywidgets' error when running IPyhon.widgets [closed]

I have IPython 4.0.1 installed. I cannot figure out the cause of the following error -

>>> from IPython.html import widgets
>>> k = widgets.Box
Traceback (most recent call last):
  File "C:\Python34\lib\site-packages\IPython\utils\shimmodule.py", line 90, in __getattr__
    return import_item(name)
  File "C:\Python34\lib\site-packages\IPython\utils\importstring.py", line 31, in import_item
    module = __import__(package, fromlist=[obj])
ImportError: No module named 'ipywidgets'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<pyshell#8>", line 1, in <module>
    k = widgets.Box
  File "C:\Python34\lib\site-packages\IPython\utils\shimmodule.py", line 92, in __getattr__
    raise AttributeError(key)
AttributeError: Box

How can I fix this?

like image 267
Yashu Seth Avatar asked Dec 18 '15 22:12

Yashu Seth


2 Answers

Between IPython 3 and IPython 4, a number of components were split into separate packages (http://blog.jupyter.org/2015/04/15/the-big-split/). Widgets were one of the features effected.

You can install ipywidgets through the standard channels (as Yashu Seth suggests):

pip install ipywidgets
# or
conda install ipywidgets

And you should get in the habit of not importing widgets from IPython.html, since the old library structure is being deprecated.

like image 83
Eric G. Avatar answered Nov 07 '22 11:11

Eric G.


ipywidgets is not installed with IPython. Just install it.

pip install ipywidgets
like image 27
Yashu Seth Avatar answered Nov 07 '22 12:11

Yashu Seth