IPython中的IPython.html.widgets说:没有名为widgets的模块

IPython中的IPython.html.widgets说:没有名为widgets的模块,python,ipython,jupyter,jupyter-notebook,ipywidgets,Python,Ipython,Jupyter,Jupyter Notebook,Ipywidgets,上帝保佑大家。我试图在Jupyter+IPython环境下执行Cirille Rossant的《IPython交互式计算可视化食谱》一书中的代码 在我尝试之前,一切正常: from collections import OrderedDict from IPython.display import (display, clear_output, YouTubeVideo) from IPython.html.widgets import DropdownWidget 如果重新启动内核,将显示以

上帝保佑大家。我试图在Jupyter+IPython环境下执行Cirille Rossant的《IPython交互式计算可视化食谱》一书中的代码

在我尝试之前,一切正常:

from collections import OrderedDict
from IPython.display import (display, clear_output, YouTubeVideo)
from IPython.html.widgets import DropdownWidget
如果重新启动内核,将显示以下消息:

/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)
然后,我尝试通过以下方式更改第三行(问题):

但是Jupyter回答:
ImportError:无法导入名称“DropdownWidget”

有人能帮我一下吗

接下来是部分答案

嗯,在网上寻找我的问题的答案

我尝试了下一个示例,效果很好:

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()
但jupyter声称我必须这样做:
jupyter nbextension enable--py--sys前缀widgetsnbextension

我按照建议去候机楼,jupyter回答:

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'
配置要自动加载的nbextension
选择权
-------
接受值的参数实际上是full的方便别名
可配置文件,其别名列在帮助行中。更多信息
关于完整配置,请参阅“--help all”。
--调试
将日志级别设置为logging.DEBUG(最大化日志输出)
-y
对任何问题回答“是”,而不是提示。
--生成配置
生成默认配置文件
--section=(EnableNBExtensionApp.section)
默认设置:“笔记本”
要将扩展添加到哪个配置节。'“共同”将影响所有人
页。
要查看所有可用的配置文件,请使用“---help all`
[EnableNBExtensionApp]严重|初始化期间遇到错误配置:
[EnableNBExtensionApp]关键|无法识别的标志:'--py'
查看中的建议:
jupyter nbextension enable--py widgetsnbextension
,但在控制台中建议
jupyter nbextension enable--py--sys prefix widgetsnbextension
。请注意,有一点不同,但在这两种情况下,关于
--py
选项出现相同的错误


在这一刻,这个问题得到了部分回答。

好吧,我在jupyter网页()上找到了这本书的重温笔记本,而且几乎运行正常(除了一些例外,至少在第01章,我会尝试其他章节).

最后一条错误消息显示您需要首先升级笔记本电脑。大多数widget类从名称中删除了“widget”,因此
DropdownWidget
可能变成了
Dropdown
。感谢托马斯,你有理由,看看我发布的答案中的网页,所有的语法都像你说的那样发生了变化。现在我正在复习笔记本,寻找类似的变化。
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'