导入pylab时出现以下错误。
>>> import pylab
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "//anaconda/lib/python2.7/site-packages/matplotlib-1.4.1-py2.7-macosx-10.5-x86_64.egg/pylab.py", line 1, in <module>
from matplotlib.pylab import *
File "//anaconda/lib/python2.7/site-packages/matplotlib-1.4.1-py2.7-macosx-10.5-x86_64.egg/matplotlib/pylab.py", line 274, in <module>
from matplotlib.pyplot import *
File "//anaconda/lib/python2.7/site-packages/matplotlib-1.4.1-py2.7-macosx-10.5-x86_64.egg/matplotlib/pyplot.py", line 109, in <module>
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "//anaconda/lib/python2.7/site-packages/matplotlib-1.4.1-py2.7-macosx-10.5-x86_64.egg/matplotlib/backends/__init__.py", line 32, in pylab_setup
globals(),locals(),[backend_name],0)
File "//anaconda/lib/python2.7/site-packages/matplotlib-1.4.1-py2.7-macosx-10.5-x86_64.egg/matplotlib/backends/backend_tkagg.py", line 13, in <module>
import matplotlib.backends.tkagg as tkagg
File "//anaconda/lib/python2.7/site-packages/matplotlib-1.4.1-py2.7-macosx-10.5-x86_64.egg/matplotlib/backends/tkagg.py", line 7, in <module>
from matplotlib.backends import _tkagg
ImportError: cannot import name _tkagg
我的系统python信息如下: OS- Mac OS X Yosemite
Python 2.7.9 |Anaconda 1.6.1 (x86_64)| (default, Dec 15 2014, 10:37:34)
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org
我安装了 matplotlib- 1.4.1。,还有最新版本的tk。 任何建议都会非常感激?谢谢。
答案 0 :(得分:0)
先决条件
在MacOS Yosemite上安装命令行工具
command line tool- sudo xcode select --install
<强>解决方案强>
安装 pip ,然后安装mathplotlib,numpy和scipy软件包,如果你没有安装它们
Install pip- sudo easy_install pip
使用homebrew
安装 GCC使用首选库运行以下命令
Install matplotlib- sudo pip install -U matplotlib
Install numpy- sudo pip install -U numpy (can ignore if you already installed)
Install scipy- sudo pip install -U scipy (can ignore if you already installed)