MacOS で matplotlib を Python から使用するときのエラーを修正する
エラー詳細
Mac で pyenv でインストールした Python を使用している場合に、
pip でインストールした matplotlib をインポートしようとすると
以下のようなランタイムエラーが出てしまう
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.
修正方法
以下のファイルを編集する
Python のバージョンは各環境に応じて変更する必要がある
/.pyenv/versions//3.4.3/lib/python3.4/site-packages/matplotlib/mpl-data/matplotlibrc
上記ファイルを以下のように修正する
backend : TkAgg