[英]Cannot import widget from IPython.html.widgets in Jupyter notebook
[英]Cannot import matplotlib with ipython/jupyter notebook
无法通过虚拟环境使用ipython / jupyter笔记本导入matplotlib。
我可以使用控制台轻松导入matplotlib。 看过其他SO帖子后我似乎无法正确设置。
我按照这个来获得单独的ipython / jupyter内核。
当我通过jupyter检查我的位置时,我得到了
six.__file__
: '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six.pyc'
six.__file__
/ '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six.pyc'
six.__file__
/ '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six.pyc'
six.__file__
/ '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six.pyc'
six.__file__
/ '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six.pyc'
和
datutil.__file__
: '/Library/Python/2.7/site-packages/dateutil/__init__.pyc'
datutil.__file__
'/Library/Python/2.7/site-packages/dateutil/__init__.pyc'
datutil.__file__
'/Library/Python/2.7/site-packages/dateutil/__init__.pyc'
datutil.__file__
'/Library/Python/2.7/site-packages/dateutil/__init__.pyc'
datutil.__file__
'/Library/Python/2.7/site-packages/dateutil/__init__.pyc'
datutil.__file__
'/Library/Python/2.7/site-packages/dateutil/__init__.pyc'
datutil.__file__
'/Library/Python/2.7/site-packages/dateutil/__init__.pyc'
我不确定这些是否正确。 主要的jupyter错误如下
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-3-20188fbdb2fd> in <module>()
1
----> 2 import matplotlib.pyplot as plt
3 get_ipython().magic(u'matplotlib inline')
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/pyplot.py in <module>()
27 from matplotlib import docstring
28 from matplotlib.backend_bases import FigureCanvasBase
---> 29 from matplotlib.figure import Figure, figaspect
30 from matplotlib.gridspec import GridSpec
31 from matplotlib.image import imread as _imread
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/figure.py in <module>()
34 import matplotlib.colorbar as cbar
35
---> 36 from matplotlib.axes import Axes, SubplotBase, subplot_class_factory
37 from matplotlib.blocking_input import BlockingMouseInput, BlockingKeyMouseInput
38 from matplotlib.legend import Legend
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/axes.py in <module>()
18 import matplotlib.colors as mcolors
19 import matplotlib.contour as mcontour
---> 20 import matplotlib.dates as _ # <-registers a date unit converter
21 from matplotlib import docstring
22 import matplotlib.font_manager as font_manager
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/dates.py in <module>()
117
118
--> 119 from dateutil.rrule import (rrule, MO, TU, WE, TH, FR, SA, SU, YEARLY,
120 MONTHLY, WEEKLY, DAILY, HOURLY, MINUTELY,
121 SECONDLY)
/Library/Python/2.7/site-packages/dateutil/rrule.py in <module>()
17
18 from six import advance_iterator, integer_types
---> 19 from six.moves import _thread
20 import heapq
21
ImportError: cannot import name _thread
好的我通过正确使用教程修复了这个问题( http://help.pythonanywhere.com/pages/IPythonNotebookVirtualenvs )
您需要设置virtualenv,然后确保在其中安装jupyter。 我正在使用全球安装的jupyter。
然后设置新的jupyter内核(上面链接),一切都应该与你指向正确的virtualenv一起工作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.