Code Log


matplotlibをimportしたら"Python is not installed as a framework."というエラーが出た



>>> from pylab import plot, show
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/UserName/.local/share/virtualenvs/chap2-U29tY3uW/lib/python3.6/site-packages/", line 1, in <module>
    from matplotlib.pylab import *
  File "/Users/UserName/.local/share/virtualenvs/chap2-U29tY3uW/lib/python3.6/site-packages/matplotlib/", line 252, in <module>
    from matplotlib import cbook, mlab, pyplot as plt
  File "/Users/UserName/.local/share/virtualenvs/chap2-U29tY3uW/lib/python3.6/site-packages/matplotlib/", line 115, in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File "/Users/UserName/.local/share/virtualenvs/chap2-U29tY3uW/lib/python3.6/site-packages/matplotlib/backends/", line 62, in pylab_setup
    [backend_name], 0)
  File "/Users/UserName/.local/share/virtualenvs/chap2-U29tY3uW/lib/python3.6/site-packages/matplotlib/backends/", line 17, in <module>
    from matplotlib.backends import _macosx
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 and replace the use of 'python' with 'pythonw'. See 'Working with Matplotlib on OSX' in the Matplotlib FAQ for more information.


vim ~/.matplotlib/matplotlibrc

matplotlibrcというファイルを作り、ファイルの中にbackend: TkAggと書けばOKです。