[Mac OS] What to do when Python is not installed as a framework. Is displayed when import matplotlib is performed.

environment

Mac OS 10.12.9 Python 3.6.* matplotlib 2.0.2

What is matplotlib

A handy tool for drawing graphs in python

A trap that Mac users get caught when using matplotlib for the first time

Probably, if you try to use matplotlib without creating any config file, you will get the following error.

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.

Solution

I referred to this stack over flow. Installation Issue with matplotlib Python [duplicate]

Create a file called matplotlibrc under ~ / .matplotlib / and add the following code.

matplotlibrc


backend: TkAgg

If you save this, you will be able to import it immediately without any problems.

I got stuck in the same place about two years ago, I completely forgot and got the same error on my new mac.

Thank you for your hard work.

Recommended Posts

[Mac OS] What to do when Python is not installed as a framework. Is displayed when import matplotlib is performed.
What to do if you get the error RuntimeError: Python is not installed as a framework when trying to use matplitlib and pylab in Python 3.3
What to do when a warning message is displayed in pip list
What to do when "cannot import name xxx" [Python]
[Python] Type Error:'WebElement' object is not iterable What to do when an error occurs
What to do if you get an error when importing matplotlib in Python (Mac)
What to do if the progress bar is not displayed in tqdm of python
What to do if Python IntelliSense is not displayed in VS Code on Windows
What to do if the image is not displayed using matplotlib etc. in the Docker container
What to do when a Missing artifact occurs in a jar that is not defined in pom.xml
What to do when the value type is ambiguous in Python?
[Beginner] What to do when "[Errno 2] File b'test.csv' does not exist: b'test.csv" is displayed when reading pandas csv
[virtualbox] What to do when [Could not retrieve mirrorlist] appears when yum update is performed on CentOS7
[VSCode] unable to import'google.cloud' What to do when pylint (import-error) does not recognize the Python import statement
NameError: global name'dot_parser' is not defined and what to do when it comes up in python
What to do if there is a decimal in python json .dumps
[Python] What to do when an error related to SSL authentication is returned
What happens if you do "import A, B as C" in Python?
Notes on what to do when matplotlib scatter () / scatter3d () does not work
How to write what to do when an application is first displayed in Qt for Python with Designer
What to do if you installed pyenv on Mac OS using Homebrew but the python version doesn't switch
I tried to explain what a Python generator is for as easily as possible.
What to do when a warning appears around Python integration in Neovim's CheckHealth
What to do if abort is displayed when inputting camera video in OpenCV
[EC2] What to do when selenium is stuck and processing does not proceed
What to do if Japanese language support is not completely installed on Ubuntu 16.04
What to do if (base) is displayed at the beginning of the Mac terminal
What to do when python3 type venv does not work well on Raspberry Pi
What to do when is not in the sudoers file.This incident will be reported.
[Python] What to do when No module named'pyproj.datadir' appears when Exe is done with PyInstaller
What to do when only the window is displayed and nothing is displayed in pygame Note
What to do when Python starts up in Anaconda does not come out unexpectedly
What to do if you get an Import Error when importing matplotlib with Jupyter
curl: (60) What to do when Issuer certificate is invalid.
What to do when gdal_merge creates a huge file
To myself as a Django beginner (2) --What is MTV?
What to do if pyenv is not enabled (zsh)
What to do when you can't bind CaboCha to Python
What to do when there is no response due to Proxy setting in Python web scraping
What to do if the message "Not recognized as an internal or external command, operable program or batch file" is displayed when executing the conda command after installing Miniconda.
When Pydev is not displayed even after adding Pydev5.2 to Eclipse (2016/8/30)
What to do when PyCharm font is strange or garbled
What to do when a Remove Error occurs when updating conda
What to do when Unalignable boolean Series provided as indexer
Grayscale image is displayed as a color image in OpenCV / Python
What to do when an error occurs with import _ssl
What to do when "SSL: CERTIFICATE_VERIFY_FAILED _ssl.c: 1056" appears in Python
What to do if `pip install matplotlib` fails on Mac
Why django-import-export import is so slow and what to do
Python list is not a list
What to do when a part of the background image becomes transparent when the transparent image is combined with Pillow
[Definition] What is a framework?
What is a python map?
[AWS] What to do when the ping command causes a "timeout"
What to do if you get a minus zero in Python
What to do when a video cannot be read by cv2.VideoCapture
[Beanstalk] What to do when an error occurs with import uuid
What to do if python says "fatal error:'stdio.h' file not found"
What to do when the jupyterlab extension settings are not reflected
What to do if Insecure Platform Warning appears when running Python
What to do if PyAudio cannot be installed on Python 3.7, 3.8, 3.9 on Windows