尝试加载matplotlib时发生iPython笔记本错误

尝试加载matplotlib时发生iPython笔记本错误,python,pandas,ipython,anaconda,Python,Pandas,Ipython,Anaconda,我想通过看这个视频来学习熊猫:。我下载了笔记本(),并加载了练习-1。第一个街区 %matplotlib inline import pandas as pd 给我这个错误: --------------------------------------------------------------------------- ImportError Traceback (most recent call last) <ipyth

我想通过看这个视频来学习熊猫:。我下载了笔记本(),并加载了练习-1。第一个街区

%matplotlib inline
import pandas as pd
给我这个错误:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-10-5761ac74df30> in <module>()
----> 1 get_ipython().magic(u'matplotlib inline')
      2 import pandas as pd

/Users/***/anaconda/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in magic(self, arg_s)
   2305         magic_name, _, magic_arg_s = arg_s.partition(' ')
   2306         magic_name = magic_name.lstrip(prefilter.ESC_MAGIC)
-> 2307         return self.run_line_magic(magic_name, magic_arg_s)
   2308 
   2309     #-------------------------------------------------------------------------

/Users/***/anaconda/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in run_line_magic(self, magic_name, line)
   2226                 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
   2227             with self.builtin_trap:
-> 2228                 result = fn(*args,**kwargs)
   2229             return result
   2230 

/Users/***/anaconda/lib/python2.7/site-packages/IPython/core/magics/pylab.pyc in matplotlib(self, line)

/Users/***/anaconda/lib/python2.7/site-packages/IPython/core/magic.pyc in <lambda>(f, *a, **k)
    191     # but it's overkill for just that one bit of state.
    192     def magic_deco(arg):
--> 193         call = lambda f, *a, **k: f(*a, **k)
    194 
    195         if callable(arg):

/Users/***/anaconda/lib/python2.7/site-packages/IPython/core/magics/pylab.pyc in matplotlib(self, line)
     86         """
     87         args = magic_arguments.parse_argstring(self.matplotlib, line)
---> 88         gui, backend = self.shell.enable_matplotlib(args.gui)
     89         self._show_matplotlib_backend(args.gui, backend)
     90 

/Users/***/anaconda/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in enable_matplotlib(self, gui)
   3087         """
   3088         from IPython.core import pylabtools as pt
-> 3089         gui, backend = pt.find_gui_and_backend(gui, self.pylab_gui_select)
   3090 
   3091         if gui != 'inline':

/Users/***/anaconda/lib/python2.7/site-packages/IPython/core/pylabtools.pyc in find_gui_and_backend(gui, gui_select)
    237     """
    238 
--> 239     import matplotlib
    240 
    241     if gui and gui != 'auto':

/Users/***/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/matplotlib/__init__.py in <module>()
    178 # cbook must import matplotlib only within function
    179 # definitions, so it is safe to import from it here.
--> 180 from matplotlib.cbook import is_string_like
    181 from matplotlib.compat import subprocess
    182 

/Users/***/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/matplotlib/cbook.py in <module>()
     31 from weakref import ref, WeakKeyDictionary
     32 
---> 33 import numpy as np
     34 import numpy.ma as ma
     35 

/Users/***/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/numpy/__init__.py in <module>()
    183         return loader(*packages, **options)
    184 
--> 185     from . import add_newdocs
    186     __all__ = ['add_newdocs',
    187                'ModuleDeprecationWarning',

/Users/***/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/numpy/add_newdocs.py in <module>()
     11 from __future__ import division, absolute_import, print_function
     12 
---> 13 from numpy.lib import add_newdoc
     14 
     15 ###############################################################################

/Users/***/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/numpy/lib/__init__.py in <module>()
     15 from .ufunclike import *
     16 
---> 17 from . import scimath as emath
     18 from .polynomial import *
     19 #import convertcode

ImportError: cannot import name scimath
---------------------------------------------------------------------------
ImportError回溯(最近一次呼叫最后一次)
在()
---->1 get_ipython().magic(u'matplotlib inline')
2进口熊猫作为pd
/magic中的Users/***/anaconda/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc(self,arg_s)
2305 magic_名称,magic_arg_s=arg_s.分区(“”)
2306 magic_name=magic_name.lstrip(prefilter.ESC_magic)
->2307返回自我。运行幻术(幻术名称,幻术参数)
2308
2309     #-------------------------------------------------------------------------
/用户/***/anaconda/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in run\u line\u magic(self,magic\u name,line)
2226 kwargs['local\u ns']=sys.\u getframe(堆栈深度).f\u locals
2227带自建存水弯:
->2228结果=fn(*args,**kwargs)
2229返回结果
2230
/matplotlib中的Users/***/anaconda/lib/python2.7/site-packages/IPython/core/magics/pylab.pyc(self,line)
/Users/***/anaconda/lib/python2.7/site-packages/IPython/core/magic.pyc in(f,*a,**k)
191#但这一点对国家来说太过分了。
192 def魔术装饰(arg):
-->193调用=λf,*a,**k:f(*a,**k)
194
195如果可调用(arg):
/matplotlib中的Users/***/anaconda/lib/python2.7/site-packages/IPython/core/magics/pylab.pyc(self,line)
86         """
87 args=magic_arguments.parse_argstring(self.matplotlib,第行)
--->88 gui,后端=self.shell.enable_matplotlib(args.gui)
89 self.\u show\u matplotlib\u后端(args.gui,后端)
90
/enable_matplotlib(self,gui)中的Users/***/anaconda/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc
3087         """
3088从IPython.core导入pylabtools作为pt
->3089 gui,backend=pt.find\u gui\u和\u backend(gui,self.pylab\u gui\u select)
3090
3091如果gui!='内联':
/用户/***/anaconda/lib/python2.7/site-packages/IPython/core/pylabtools.pyc在find_gui_和_backend(gui,gui_select)中
237     """
238
-->239导入matplotlib
240
241如果gui和gui!=“自动”:
/Users/***/Library/enthund/Canopy_64bit/User/lib/python2.7/site packages/matplotlib/_init_uuu.py in()
178#cbook必须仅在函数中导入matplotlib
179#定义,因此从这里导入是安全的。
-->180从matplotlib.cbook导入类似字符串
181来自matplotlib.compat导入子流程
182
/Users/***/Library/enthund/Canopy_64bit/User/lib/python2.7/site-packages/matplotlib/cbook.py in()
31来自weakref导入参考,WeakKeyDictionary
32
--->33进口numpy作为np
34导入numpy.ma作为ma
35
/Users/***/Library/enthund/Canopy\u 64bit/User/lib/python2.7/site packages/numpy/\uuuuuu init\uuuuuuuuuu.py in()
183返回加载器(*包,**选项)
184
-->185从导入添加新文档
186 uuu all uuuu=['添加新文档',
187“模块化预防警告”,
/Users/***/Library/enthund/Canopy_64bit/User/lib/python2.7/site-packages/numpy/add_newdocs.py in()
11来自未来导入部门,绝对导入,打印功能
12
--->13从numpy.lib导入添加新文档
14
15 ###############################################################################
/Users/***/Library/enthund/Canopy\u 64bit/User/lib/python2.7/site packages/numpy/lib/\uuuuu init\uuuuuu.py in()
15.从UFUNCLE导入*
16
--->17.从导入scimath作为emath
18.进口*
19#导入代码
ImportError:无法导入名称scimath

有人能告诉我发生了什么事以及我如何解决它吗?

您可以阅读有关类似问题的文章并进行讨论

导入scimath的主要问题是: “ImportError:无法导入名称scimath”

您可以尝试导入scimath


更好的解决方案是设置PYTHONPATH变量,它为python解释器提供了python包/模块的附加目录。您可以阅读有关设置PYTHONPATH变量的更多信息。

谢谢您提供的信息!我刚刚更新了我的canopy模块,并将PYTHONPATH设置为包含anaconda,它成功了。我很高兴听到这个消息:)