3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PyCharmで「matplotlibrc」を使おうとしたらエラーが出た

Last updated at Posted at 2018-01-30

「機械学習」の勉強がてら、PyCharmに「matplotlibrc」を入れて色々と遊ぼうと思っていたところ以下のエラーに遭遇。

エラー内容

Traceback (most recent call last):
File "/Users/[USER_NAME]/PycharmProjects/[PROJECT_NAME]/hebi.py", line 1, in <module>
    import matplotlib.pyplot as plt
:
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.

Process finished with exit code 1

日本語でおk。

多分Pythonのパスかバージョンの差が招いたものっぽい?

対処方法

matplotlibrcの設定ファイル matplotlibrc を直接修正する。

ファイルのパスは以下。適宜変更してください。

/Users/[USER_NAME]/PycharmProjects/[PROJECT_NAME]/venv/lib/python2.7/site-packages/matplotlib/mpl-data/matplotlibrc
matplotlibrc
# If you omit this parameter, it will always default to "Agg", which is a
# non-interactive backend.
# backend      : macosx
backend: TkAgg # 【追加】

「backend」 を macosx から TkAgg に変更すればOK。

対処方法はいくつか存在しており、その中で一番手軽な方法で対処しました。

参考記事

【Mac】matplotlibをimportした際に「Python is not installed as a framework.」のエラー - from umentu import stupid

3
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
3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?