我安装了IPython 4.0.1.我无法弄清楚以下错误的原因 -
>>> 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 "", line 1, in k = widgets.Box File "C:\Python34\lib\site-packages\IPython\utils\shimmodule.py", line 92, in __getattr__ raise AttributeError(key) AttributeError: Box
我怎样才能解决这个问题?
在IPython 3和IPython 4之间,许多组件被分成不同的包(http://blog.jupyter.org/2015/04/15/the-big-split/).小部件是受影响的功能之一.
您可以通过标准渠道安装ipywidgets(正如Yashu Seth建议的那样):
pip install ipywidgets # or conda install ipywidgets
你应该养成不从IPython.html导入小部件的习惯,因为旧的库结构已被弃用.