码迷,mamicode.com
首页 > 系统相关 > 详细

mac使用matplotlib

时间:2018-06-06 15:47:10      阅读:173      评论:0      收藏:0      [点我收藏+]

标签:not   format   mac   编辑   tac   AC   bbr   文件   解决   

mac系统,安装了matplotlib之后, 导入matplotlib.pyplot的时候报错

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. If you are using (Ana)Conda
please install python.app and replace the use of python with pythonw. See Working with Matplotlib on OSX in the Matplotlib FAQ
for more information.

说python不是作为框架安装的,从stackoverflow上面找到的解决办法,现记录一下
1. cd ~/.matplotlib

2. nano matplotlibbrc
3. 在打开的文件里加一行: backend : TkAgg

nano编辑器的使用:ctrl + x 保存退出, y确认保存,回车退出

4. 在python里,使用matplotlib.pyplot之前先执行以下两行代码:

In [1]: import matplotlib

In [2]: matplotlib.use("TkAgg")

然后再导入,import matplotlib.pyplot as plt

it works!

 

mac使用matplotlib

标签:not   format   mac   编辑   tac   AC   bbr   文件   解决   

原文地址:https://www.cnblogs.com/zhang-can/p/9144430.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!