| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
To help us understand and resolve your issue, please fill out the form to the best of your ability. You can feel free to delete the sections that do not apply.
Bug summary
Matplotlib cannot seem to find any of its own fonts on my Scientific Linux system - I get all sorts of warnings like "Font family ['STIXNonUnicode'] not found" and "findfont: Could not match :family=DejaVu Sans:style=normal:variant=normal:weight=normal:stretch=normal:size=10.0. Returning /usr/share/fonts/dejavu/DejaVuSansMono-Oblique.ttf".
Code for reproduction
#!/usr/bin/env python
import matplotlib
matplotlib.use('Agg')
from matplotlib import pyplot as plt
import numpy as np
if __name__ == '__main__':
x = np.linspace(0.0, 5.0, 100)
y = np.cos(2*np.pi*x) * np.exp(-x)
plt.plot(x, y, 'k')
plt.title('Damped exponential decay')
#plt.text(2, 0.65, r'$\cos(2 \pi t) \exp(-t)$', fontname='DejaVu Sans')
plt.text(2, 0.65, r'$\cos(2 \pi t) \exp(-t)$')
plt.xlabel('time (s)')
plt.ylabel('voltage (mV)')
plt.savefig('output.png')Actual outcome
/home/pager/miniconda/envs/pager/lib/python3.6/site-packages/matplotlib/font_manager.py:1297: UserWarning: findfont: Font family ['sans-serif'] not found. Falling back to DejaVu Sans (prop.get_family(), self.defaultFamily[fontext])) /home/pager/miniconda/envs/pager/lib/python3.6/site-packages/matplotlib/font_manager.py:1307: UserWarning: findfont: Could not match :family=DejaVu Sans:style=normal:variant=normal:weight=400:stretch=normal:size=10.0. Returning /usr/share/fonts/dejavu/DejaVuSansMono-Oblique.ttf UserWarning) /home/pager/miniconda/envs/pager/lib/python3.6/site-packages/matplotlib/font_manager.py:1297: UserWarning: findfont: Font family ['STIXGeneral'] not found. Falling back to DejaVu Sans (prop.get_family(), self.defaultFamily[fontext])) /home/pager/miniconda/envs/pager/lib/python3.6/site-packages/matplotlib/font_manager.py:1307: UserWarning: findfont: Could not match :family=DejaVu Sans:style=normal:variant=normal:weight=normal:stretch=normal:size=10.0. Returning /usr/share/fonts/dejavu/DejaVuSansMono-Oblique.ttf UserWarning) /home/pager/miniconda/envs/pager/lib/python3.6/site-packages/matplotlib/font_manager.py:1307: UserWarning: findfont: Could not match :family=DejaVu Sans:style=italic:variant=normal:weight=normal:stretch=normal:size=10.0. Returning /usr/share/fonts/dejavu/DejaVuSansMono-Oblique.ttf UserWarning) /home/pager/miniconda/envs/pager/lib/python3.6/site-packages/matplotlib/font_manager.py:1307: UserWarning: findfont: Could not match :family=DejaVu Sans:style=normal:variant=normal:weight=700:stretch=normal:size=10.0. Returning /usr/share/fonts/dejavu/DejaVuSansMono-Oblique.ttf UserWarning) /home/pager/miniconda/envs/pager/lib/python3.6/site-packages/matplotlib/font_manager.py:1297: UserWarning: findfont: Font family ['STIXNonUnicode'] not found. Falling back to DejaVu Sans (prop.get_family(), self.defaultFamily[fontext])) /home/pager/miniconda/envs/pager/lib/python3.6/site-packages/matplotlib/font_manager.py:1297: UserWarning: findfont: Font family ['STIXSizeOneSym'] not found. Falling back to DejaVu Sans (prop.get_family(), self.defaultFamily[fontext])) /home/pager/miniconda/envs/pager/lib/python3.6/site-packages/matplotlib/font_manager.py:1297: UserWarning: findfont: Font family ['STIXSizeTwoSym'] not found. Falling back to DejaVu Sans (prop.get_family(), self.defaultFamily[fontext])) /home/pager/miniconda/envs/pager/lib/python3.6/site-packages/matplotlib/font_manager.py:1297: UserWarning: findfont: Font family ['STIXSizeThreeSym'] not found. Falling back to DejaVu Sans (prop.get_family(), self.defaultFamily[fontext])) /home/pager/miniconda/envs/pager/lib/python3.6/site-packages/matplotlib/font_manager.py:1297: UserWarning: findfont: Font family ['STIXSizeFourSym'] not found. Falling back to DejaVu Sans (prop.get_family(), self.defaultFamily[fontext])) /home/pager/miniconda/envs/pager/lib/python3.6/site-packages/matplotlib/font_manager.py:1297: UserWarning: findfont: Font family ['STIXSizeFiveSym'] not found. Falling back to DejaVu Sans (prop.get_family(), self.defaultFamily[fontext])) /home/pager/miniconda/envs/pager/lib/python3.6/site-packages/matplotlib/font_manager.py:1297: UserWarning: findfont: Font family ['cmsy10'] not found. Falling back to DejaVu Sans (prop.get_family(), self.defaultFamily[fontext])) /home/pager/miniconda/envs/pager/lib/python3.6/site-packages/matplotlib/font_manager.py:1297: UserWarning: findfont: Font family ['cmr10'] not found. Falling back to DejaVu Sans (prop.get_family(), self.defaultFamily[fontext])) /home/pager/miniconda/envs/pager/lib/python3.6/site-packages/matplotlib/font_manager.py:1297: UserWarning: findfont: Font family ['cmtt10'] not found. Falling back to DejaVu Sans (prop.get_family(), self.defaultFamily[fontext])) /home/pager/miniconda/envs/pager/lib/python3.6/site-packages/matplotlib/font_manager.py:1297: UserWarning: findfont: Font family ['cmmi10'] not found. Falling back to DejaVu Sans (prop.get_family(), self.defaultFamily[fontext])) /home/pager/miniconda/envs/pager/lib/python3.6/site-packages/matplotlib/font_manager.py:1297: UserWarning: findfont: Font family ['cmb10'] not found. Falling back to DejaVu Sans (prop.get_family(), self.defaultFamily[fontext])) /home/pager/miniconda/envs/pager/lib/python3.6/site-packages/matplotlib/font_manager.py:1297: UserWarning: findfont: Font family ['cmss10'] not found. Falling back to DejaVu Sans (prop.get_family(), self.defaultFamily[fontext])) /home/pager/miniconda/envs/pager/lib/python3.6/site-packages/matplotlib/font_manager.py:1297: UserWarning: findfont: Font family ['cmex10'] not found. Falling back to DejaVu Sans (prop.get_family(), self.defaultFamily[fontext])) /home/pager/miniconda/envs/pager/lib/python3.6/site-packages/matplotlib/font_manager.py:1297: UserWarning: findfont: Font family ['DejaVu Sans Display'] not found. Falling back to DejaVu Sans (prop.get_family(), self.defaultFamily[fontext])) /home/pager/miniconda/envs/pager/lib/python3.6/site-packages/matplotlib/font_manager.py:1307: UserWarning: findfont: Could not match :family=DejaVu Sans:style=normal:variant=normal:weight=400:stretch=normal:size=12.0. Returning /usr/share/fonts/dejavu/DejaVuSansMono-Oblique.ttf UserWarning)
Expected outcome
On my Mac, there are no warnings.
Matplotlib version
matplotlib.version => '2.0.0'
Python 3.6.1 | packaged by conda-forge | (default, Mar 23 2017, 21:05:12)
Linux localhost 3.10.0-514.10.2.el7.x86_64 #1 SMP Thu Mar 2 11:21:24 CST 2017 x86_64 x86_64 x86_64 GNU/Linux
Scientific Linux release 7.3 (Nitrogen)
Python and matplotlib were both installed using conda from conda-forge.
Also, I have made NO customizations in any matplotlibrc files, and there are no files under ~/.config/matplotlib.
The actual problem caused by all of this is of course in a much more complicated application, where a map I'm making has the wrong font (italicized, at that) in it when created on Linux.
Incidentally, I could really use a workaround, as I was hoping to deploy some code on Linux this week. Is there a way to tell matplotlib (perhaps in a matplotlibrc file) where to find the true type fonts that are included with the distribution?
| Back | FazBrowse Home | New Git URL |
Activity
tacaswell commented on Apr 4, 2017
Try clearing out everything in ~/.cache/matplotlib
I don't see why you are trying to hit the computer modern fonts.
The paths to the shipped fonts are hard coded here
mhearne-usgs commented on Apr 4, 2017
Clearing out the cache (I didn't know about that) solved the problem.
I don't understand your comment about trying to "hit" computer modern fonts...?
tacaswell commented on Apr 4, 2017
UserWarning: findfont: Font family ['cmsy10'] not found <- reporting that it can not find computer modern.
Great the clearing the cache solved your problem! Closing this as resolved.
pierreguilmin commented on Jun 8, 2021
To find where is located the cache that @tacaswell proposes to clear out (in my case it was in ~/.matplotlib):
JohnReid commented on Mar 21, 2022
I had to drop an _ to get that to work: