TIL: Python matplotlib Import 문제 해결

참고 : https://hashbox.github.io/Matplotlib-Mac-%EC%82%AC%EC%9A%A9

맥에서 Python Matplotlib Import문제 해결 방법

학교 프로젝트를 진행하기 위해 사전 공부를 (tensorflow) 하려고 하는데, matplotlib를 설치하고 import하는 과정에서 다음과 같은 에러가 나타났다.

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.

맥에서는 matplotlib를 사용하는데 있어서 추가적이 조치가 필요하다는 것을 참고 사이트를 통해 알았다.

  1. 스크립트 내 표시
import matplotlib
matplotlib.use('TkAgg')
  1. ~/.matplotlib/matplotlibrc 경로에 파일 추가
echo "backend: TkAgg" >> ~/.matplotlib/matplotlibrc

이케만하면 잘 돌아간다! 끝!