matplotlib Python的安装问题[复制]

本文翻译自:Installation Issue with matplotlib Python [duplicate]

This question already has an answer here: 这个问题在这里已有答案:

I have issue after installing the matplotlib package unable to import matplotlib.pyplot as plt . 我在安装matplotlib软件包后无法将matplotlib.pyplot作为plt导入 Any suggestion will be greatly appreciate. 任何建议都将非常感激。

>>> import matplotlib.pyplot as plt
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "//anaconda/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-macosx-10.5-x86_64.egg/matplotlib/pyplot.py", line 98, in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File "//anaconda/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-macosx-10.5-x86_64.egg/matplotlib/backends/__init__.py", line 28, in pylab_setup
    globals(),locals(),[backend_name],0)
  File "//anaconda/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-macosx-10.5-x86_64.egg/matplotlib/backends/backend_macosx.py", line 21, in <module>
    from matplotlib.backends import _macosx
**RuntimeError**: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly if Python is not installed as a framework. See the Python documentation for more information on installing Python as a framework on Mac OS X. Please either reinstall Python as a framework, or try one of the other backends.

#1楼

参考:https://stackoom.com/question/1TPBB/matplotlib-Python的安装问题-复制


#2楼

Problem Cause In mac os image rendering back end of matplotlib (what-is-a-backend to render using the API of Cocoa by default). 问题原因在mac os图像渲染中,matplotlib的后端(默认情况下使用Cocoa的API渲染的后端是什么)。 There is Qt4Agg and GTKAgg and as a back-end is not the default. 有Qt4Agg和GTKAgg,作为后端不是默认值。 Set the back end of macosx that is differ compare with other windows or linux os. 设置macosx的后端与其他windows或linux os相比有所不同。

I resolve this issue following ways: 我通过以下方式解决此问题:

  • I assume you have installed the pip matplotlib, there is a directory in you root called ~/.matplotlib . 我假设您已经安装了pip matplotlib,您的根目录中有一个名为~/.matplotlib
  • Create a file ~/.matplotlib/matplotlibrc there and add the following code: backend: TkAgg 在那里创建一个~/.matplotlib/matplotlibrc文件并添加以下代码: backend: TkAgg

From this link you can try different diagram. 从这个链接你可以尝试不同的图表。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值