【Python】matplotlib.pyplotインポート時にPython is not installed as a frameworkのRuntimeError

実践機械学習システムで手を動かしていたところ、import 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 Working with Matplotlib in a virtual enviroment see 'Working with Matplotlib in Virtual environments' in the Matplotlib FAQ

環境

Python 2.7.11
matplotlib 1.5.1

解決策

~/.matplotlib下にmatplotlibrcを作成し、

backend : TkAgg

と書き込んで保存。

対話環境を再起動してmatplotlib.pyplotを読みこめば上手くいくはず。