【问题标题】:Matplotlib/Pylab installation issue and can not import in _tkagg?Matplotlib/Pylab 安装问题,无法导入 _tkagg?
【发布时间】:2015-08-28 03:48:59
【问题描述】:

导入 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信息如下: 操作系统- 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

我安装了 ma​​tplotlib- 1.4.1. 并且还有最新版本的 tk。 任何建议将不胜感激?谢谢。

【问题讨论】:

标签: python matplotlib


【解决方案1】:

先决条件

在 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) 

【讨论】:

    猜你喜欢
    • 2013-03-20
    • 1970-01-01
    • 1970-01-01
    • 2014-10-08
    • 2015-11-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-06
    相关资源
    最近更新 更多