macos – matplotlib: RuntimeError: Python is not installed as a framework

macos – matplotlib: RuntimeError: Python is not installed as a framework

I run my script in virtualenv. Python version is 3.5.

Add a line:

backend: TkAgg

in file:

~/.matplotlib/matplotlibrc

This solved the problem.

If you want to know more about why adding this solves the problem, you can read about customizing matplotlibs backend. And TkAgg solves this issue because of its dependency with Tkinter.

Below worked for me:

import matplotlib  
matplotlib.use(TkAgg)   
import matplotlib.pyplot as plt  

Reference:
https://github.com/tensorflow/tensorflow/issues/2375

macos – matplotlib: RuntimeError: Python is not installed as a framework

I installed Jupyter Notebook in virtualenv and below worked for me:

At Console:

echo backend: TkAgg >> ~/.matplotlib/matplotlibrc
pip install matplotlib==2.1.0

On Notebook:

import matplotlib

Restart the kernel:

dataframe.plot.hist()
...

In my opinion, it will fix the error.

Leave a Reply

Your email address will not be published. Required fields are marked *