2015-09-07 185 views
2

我试过安装jupyter,但不知何故它不能与matplotlib三维图形一起工作。我总是会遇到以下错误:完全删除Jupyter


AttributeError       Traceback (most recent call last) 
<ipython-input-1-dd74dfec8882> in <module>() 
     9 
    10 fig = plt.figure() 
---> 11 ax = fig.gca(projection='3d') 
    12 X, Y, Z = axes3d.get_test_data(0.05) 
    13 ax.plot_surface(X, Y, Z, rstride=8, cstride=8, alpha=0.3) 

/usr/local/lib/python2.7/dist-packages/matplotlib/figure.pyc in gca(self, **kwargs) 
    1272 
    1273   # no axes found, so create one which spans the figure 
-> 1274   return self.add_subplot(1, 1, 1, **kwargs) 
    1275 
    1276  def sca(self, a): 

/usr/local/lib/python2.7/dist-packages/matplotlib/figure.pyc in add_subplot(self, *args, **kwargs) 
    962      self._axstack.remove(ax) 
    963 
--> 964    a = subplot_class_factory(projection_class)(self, *args, **kwargs) 
    965 
    966   self._axstack.add(key, a) 

/usr/local/lib/python2.7/dist-packages/matplotlib/axes/_subplots.pyc in __init__(self, fig, *args, **kwargs) 
    76 
    77   # _axes_class is set in the subplot_class_factory 
---> 78   self._axes_class.__init__(self, fig, self.figbox, **kwargs) 
    79 
    80  def __reduce__(self): 

/usr/lib/pymodules/python2.7/mpl_toolkits/mplot3d/axes3d.pyc in __init__(self, fig, rect, *args, **kwargs) 
    89   Axes.__init__(self, fig, rect, 
    90      frameon=True, 
---> 91      *args, **kwargs) 
    92   # Disable drawing of axes by base class 
    93   Axes.set_axis_off(self) 

/usr/local/lib/python2.7/dist-packages/matplotlib/axes/_base.pyc in __init__(self, fig, rect, axisbg, frameon, sharex, sharey, label, xscale, yscale, **kwargs) 
    435   self._hold = rcParams['axes.hold'] 
    436   self._connected = {} # a dict from events to (id, func) 
--> 437   self.cla() 
    438   # funcs used to format x and y - fall back on major formatters 
    439   self.fmt_xdata = None 

/usr/lib/pymodules/python2.7/mpl_toolkits/mplot3d/axes3d.pyc in cla(self) 
    1043   self._zmargin = 0 
    1044 
-> 1045   Axes.cla(self) 
    1046 
    1047   self.grid(rcParams['axes3d.grid']) 

/usr/local/lib/python2.7/dist-packages/matplotlib/axes/_base.pyc in cla(self) 
    906   self.containers = [] 
    907 
--> 908   self.grid(self._gridOn, which=rcParams['axes.grid.which']) 
    909   props = font_manager.FontProperties(size=rcParams['axes.titlesize'], 
    910           weight=rcParams['axes.titleweight']) 

/usr/lib/pymodules/python2.7/mpl_toolkits/mplot3d/axes3d.pyc in grid(self, b, **kwargs) 
    1254   if len(kwargs) : 
    1255    b = True 
-> 1256   self._draw_grid = maxes._string_to_bool(b) 
    1257 
    1258  def ticklabel_format(self, **kwargs) : 

AttributeError: 'module' object has no attribute '_string_to_bool'    

这之前我安装Jupyter没有发生,所以我想删除Jupyter会有所帮助。我已经运行

pip uninstall jupyter 

,并在主目录中删除.ipython.jupyter目录,但每当我跑

ipython notebook 

的Jupyter布局仍然存在,我仍然得到同样的错误...我甚至尝试卸载并再次安装ipythonipython-notebook,但它仍然无法正常工作。

有什么建议吗?我不太了解内核...

非常感谢。

+0

发布错误时,请始终包含完整的回溯。 – cel

+0

您是否尝试删除'.local'目录,我不太确定该目录的名称。 – Gnimuc

+0

我删除'.local'目录后,它仍然不起作用... –

回答

0

看起来像matplotlib的apt包的问题。在我做了apt-get purge matplotlibapt-get autoremove matplotlib之后,再加上pip install matplotlib,它就起作用了。

感谢,

0

如果您使用的是Anaconda安装SciPy的,你可以使用conda update matplotlib。这导致python,matplotlib,numpy和其他一些软件包为我更新。 Matplotlib然后能够被导入并正常工作。我不需要这样卸载任何东西。 Jupyter继续工作。