LoginSignup
2
4

More than 5 years have passed since last update.

【Mac OS】import matplotlibした時にPython is not installed as a framework.と出た時の対処法

Posted at

環境

Mac OS 10.12.9
Python 3.6.*
matplotlib 2.0.2

matplotlibとは

pythonでグラフを描ける便利ツール

Macユーザーが初めてmatplotlibを使う時に引っかかる罠

おそらく、なんの設定ファイルを作らずに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. 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.

解決法

このstack over flowを参考にしました。
Installation Issue with matplotlib Python [duplicate]

~/.matplotlib/以下にmatplotlibrcというファイルを作って以下のコードを追加します。

matplotlibrc
backend: TkAgg

これを保存すればすぐに問題なくimportできるようになります。

2年前くらいにも同じところで詰まったのですが、
すっかり忘れて新しいmacでも同じエラーに引っかかりました。

お疲れ様でした。

2
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
4