出现的问题:
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.
出现的原因:
在Mac OS X的图像渲染后端,默认使用的是cocoa的API.这里我们需要自己设置为TkAgg
.
解决方法
-
matplotlib
安装成功后,会在根目录生成.matplotlib
的文件夹,在终端使用cd命令进入.
$ cd .matplotlib/
- 创建一个文件命名为:
matplotlibrc
,并添加内容:backend: TkAgg
.
ps.可以用vim编译器创建文件并插入内容
$ vim matplotlibrc
参考资料:stackoverflow
网友评论