出現(xiàn)的問(wèn)題:
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.
出現(xiàn)的原因:
在Mac OS X的圖像渲染后端,默認(rèn)使用的是cocoa的API.這里我們需要自己設(shè)置為TkAgg
.
解決方法
-
matplotlib
安裝成功后,會(huì)在根目錄生成.matplotlib
的文件夾,在終端使用cd命令進(jìn)入.
$ cd .matplotlib/
- 創(chuàng)建一個(gè)文件命名為:
matplotlibrc
,并添加內(nèi)容:backend: TkAgg
.
ps.可以用vim編譯器創(chuàng)建文件并插入內(nèi)容
$ vim matplotlibrc
參考資料:stackoverflow