无法使用mplot3d,收到错误:AttributeError:' module'对象没有属性' _string_to_bool'

时间:2017-03-07 21:36:57

标签: macos python-2.7 matplotlib mplot3d

我试图使用mplot3d来绘制3D内容。我有Mac OSX。但是我收到了这个错误:

  ax = fig.gca(projection = '3d')
File "/usr/local/lib/python2.7/site-packages/matplotlib/figure.py", line 1368, in gca
  return self.add_subplot(1, 1, 1, **kwargs)
File "/usr/local/lib/python2.7/site-packages/matplotlib/figure.py", line 1020, in add_subplot
  a = subplot_class_factory(projection_class)(self, *args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/matplotlib/axes/_subplots.py", line 73, in __init__
 self._axes_class.__init__(self, fig, self.figbox, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mpl_toolkits/mplot3d/axes3d.py", line 91, in __init__
*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/matplotlib/axes/_base.py", line 551, in __init__
self.cla()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mpl_toolkits/mplot3d/axes3d.py", line 1045, in cla
  Axes.cla(self)
File "/usr/local/lib/python2.7/site-packages/matplotlib/axes/_base.py", line 1062, in cla
  self.grid(False)  # Disable grid on init to use rcParameter
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mpl_toolkits/mplot3d/axes3d.py", line 1256, in grid
  self._draw_grid = maxes._string_to_bool(b)
AttributeError: 'module' object has no attribute '_string_to_bool'

我在这里搜索了这个问题并尝试了一堆解决方案。我正在使用matplotlib 2.0.0:

  • 删除mplot3d(位于/usr/local/lib/python2.7/site-packages/mpl_toolkits)并重新安装/升级:pip install --upgrade' matplotlib [mplot3d]'
  • 将此行添加到/usr/lib/pymodules/python2.7/mpl_toolkits/mplot3d/axes3d.py: 来自matplotlib.cbook import _string_to_bool

这两项都不起作用,我仍然遇到同样的错误。有什么建议?谢谢!

0 个答案:

没有答案