'jupyter notebook shows error message for matplotlib Bad key "text.kerning_factor"

import pandas as pd 
import numpy as np
import matplotlib.pyplot as plt

Bad key "text.kerning_factor" on line 4 in /home/samyak/anaconda3/lib/python3.7/site-packages/matplotlib/mpl-data/stylelib/_classic_test_patch.mplstyle. You probably need to get an updated matplotlibrc file from https://github.com/matplotlib/matplotlib/blob/v3.1.3/matplotlibrc.template or from the matplotlib source distribution



Solution 1:[1]

It seems to be the case that one of style config files is for matplotlib 3.1 despite that 3.2 is installed.

  1. Go to /home/samyak/anaconda3/lib/python3.7/site-packages/matplotlib/mpl-data/stylelib/

  2. open _classic_test_patch.mplstyle and comment out the line of text.kerning_factor:6

It worked for me.

Solution 2:[2]

I had the same problem and I solved it by upgrading Matplotlib using the code:

conda upgrade matplotlib

or

pip install --upgrade matplotlib

Solution 3:[3]

I encountered the same issue today (using version 3.2.1).

My solution: Reinstall matplotlib :)

Solution 4:[4]

I noticed the version of matplotlib that print(matplotlib.__version__) returned was different from the version that pip show matplotlib showed! When I checked the folder ./Anaconda3/Lib/site-packages I noticed there were two versions of matplotlib (and a few other packages, too). For some reason when I upgraded matplotlib (and other packages), the old versions were not uninstalled. I used

pip uninstall matplotlib

twice to remove both versions, then installed matplotlib again. This solved the problem.

Solution 5:[5]

I also encountered the same problem. Reinstalling matplotlib didn't work for me. I downgraded matplotlib to version 2 using:

conda install matplotlib=2

It worked. Hope this helps.

Solution 6:[6]

  1. Install matplotlib from the active environment.
  2. Go to './Anaconda3/Lib/site-packages' and manually delete all the matplotlib folders you see there. Make sure you are in the same environment if you have more than one.
  3. Re-install 'matplotlib' using conda install -c conda-forge matplotlib.

It should work.

Solution 7:[7]

For me it sufficed to install/upgrade the current version of matplotlib from conda-forge instead of the default channel (no previous uninstall necessary):

conda install -c conda-forge matplotlib

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 T_T
Solution 2 Sam Texas
Solution 3 Andrei Margeloiu
Solution 4 Reza Dodge
Solution 5 deep s. pandey
Solution 6 Hadij
Solution 7 Robert