HaneCa

独り立ちへ向けた長い道

matplotlibをvenv環境で利用する場合のエラー

投稿日: 2018年12月2日 最終更新日: 2019年1月1日

データを解析するため、matplotlibを利用して、データをグラフに表示しようとした時に、次のようなエラーが発生しました。

mportError: 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. Seethe 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 theother 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.

これは、macでmatplotlibを利用する場合、表示にCocoa APIを利用しているそうなのですが、それをimportできないことがエラーの原因のようです。

これを解決する方法として、matplotlibのデフォルトの設定で、backendの部分をTkAggにすることで解決するようです。

解決方法

ファイルのパス: ~/.matplotlib/matplotlibrc

ファイルに追記する内容:

backend: TkAgg

参考サイト

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください