Luis Salazar
Luis Salazar

Reputation: 31

IPython.html.widgets in IPython say: no module named widgets

God day for all. I'm trying to execute code from book "IPython Interactive Computing an Visualizing Cookbook" of Cirille Rossant on a Jupyter + IPython environment.

All work fine until I try:

from collections import OrderedDict
from IPython.display import (display, clear_output, YouTubeVideo)
from IPython.html.widgets import DropdownWidget

If I do restart to the kernel appear this message:

/usr/local/lib/python3.4/dist-packages/IPython/html.py:14: ShimWarning: The `IPython.html` package has been deprecated. You should import from `notebook` instead. `IPython.html.widgets` has moved to `ipywidgets`.
  "`IPython.html.widgets` has moved to `ipywidgets`.", ShimWarning)

then I try to change the third line (the problem) by:

from ipywidgets import DropdownWidgets

but Jupyter answer: ImportError: cannot import name 'DropdownWidget'

Can somebody help me about?

The next is a partial answer

Well, seeking on the web I find in this page ipywidgets installation the answer to my question and problem.

I try the next expample and work fine:

import numpy as np
url = "http://donnees.ville.montreal.qc.ca/dataset/f170fecc-18db-44bc-b4fe-5b0b6d2c7297/resource/ec12447d-6b2a-45d0-b0e7-fd69c382e368/download/2013.csv"
df = pd.read_csv(url, index_col='Date', parse_dates=True, dayfirst=True)
from ipywidgets import interact
@interact
def plot(n=(1, 30)):
    pd.rolling_mean(df['Berri1'], n).dropna().plot()
    plt.ylim(0, 8000)
    plt.show()

but jupyter claim that I have to do: jupyter nbextension enable --py --sys-prefix widgetsnbextension

I go to the terminal obeying the suggestion and jupyter respond:

Configure an nbextension to be automatically loaded

Options
-------

Arguments that take values are actually convenience aliases to full
Configurables, whose aliases are listed on the help line. For more information
on full configurables, see '--help-all'.

--debug
    set log level to logging.DEBUG (maximize logging output)
-y
    Answer yes to any questions instead of prompting.
--generate-config
    generate default config file
--section=<Unicode> (EnableNBExtensionApp.section)
    Default: 'notebook'
    Which config section to add the extension to. 'common' will affect all
    pages.

To see all available configurables, use `--help-all`

[EnableNBExtensionApp] CRITICAL | Bad config encountered during initialization:
[EnableNBExtensionApp] CRITICAL | Unrecognized flag: '--py'

Look that in 1 have the suggestion: jupyter nbextension enable --py widgetsnbextension but in the console suggest jupyter nbextension enable --py --sys-prefix widgetsnbextension. Note that there is a little difference but in both cases appear the same error about --py option

In this moment the question is partially answered.

Upvotes: 2

Views: 3902

Answers (1)

Luis Salazar
Luis Salazar

Reputation: 31

Well, seeking on web I find on jupyter web page (jupyter) the revisited notebooks of the book and extraneously almost run fine (with some exceptions, at least on chapter 01, I go to try with the other chapters).

Upvotes: 1

Related Questions