Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 613
Samyak L Avatar asked Apr 12 '20 12:04

Samyak L


4 Answers

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.

like image 55
Reza Dodge Avatar answered Oct 09 '22 15:10

Reza Dodge


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.

like image 16
T_T Avatar answered Nov 15 '22 12:11

T_T


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

conda upgrade matplotlib

or

pip install --upgrade matplotlib
like image 6
Samuel Mandillah Avatar answered Nov 15 '22 12:11

Samuel Mandillah


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

My solution: Reinstall matplotlib :)

like image 4
Andrei Margeloiu Avatar answered Nov 15 '22 12:11

Andrei Margeloiu