Matplotlib takes time on import

I just updated to the latest stable version of matplotlib (1.5.1), and every time I import matplotlib, I get this message:

 /usr/local/lib/python2.7/dist-packages/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment. warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.') 

... which always stops for a few seconds.

Is this the expected behavior? Was it the same before, but only without a printed message?

+83
python matplotlib
Jan 13 '16 at 15:54
source share
7 answers

As stated in the comment above, deleting the files:

 fontList.cache fontList.py3k.cache tex.cache 

solve the problem of. In my case, the files were under:

 `~/.matplotlib` 

edited

A few days ago the message appeared again, I deleted the files in the places mentioned above without any success. I found that, as suggested here , T Mudau , extra space with cache text files: ~/.cache/fontconfig

+104
Jan 25 '16 at 18:33
source share

Hugo Approach Approved for Ubuntu 14.04 LTS / matplotlib 1.5.1:

  • remote ~ / .cache / matplotlib / fontList.cache
  • executed the code, a warning was issued again (assumption: it restores the cache correctly).
  • code running again, no more warnings (finally)
+19
Aug 08 '16 at 12:52 on
source share

On OSX Yosemite (version 10.10.15), the following worked for me:

  • delete the cache files from this directory: ~ / .cache / fontconfig (as suggested by tom)
  • also deleted .cache files in ~ / .matplotlib (as suggested by Hugo)
+8
Feb 14 '16 at 21:24
source share

I ran python code using sudo only once and it resolved the warning for me. Now it works faster. Running without sudo gives no warning.

Greetings

+8
Apr 16 '16 at 16:43
source share

I ran the python w code. sudo, and he cured it ... I assumed that there was no permission to write this table ... good luck!

+2
Feb 14 '16 at 22:49
source share

HI you should find this file: font_manager.py in my case: C: \ Users \ gustavo \ Anaconda3 \ Lib \ site-packages \ matplotlib \ font_manager.py

and FIND def win32InstalledFonts (directory = None, fontext = 'ttf') and replace with:

def win32InstalledFonts (directory = None, fontext = 'ttf'): "" Search for fonts in the specified font directory or use system directories if they are not specified. TrueType font list file names are returned by default or AFM fonts if fontext == "AFM". ""

 from six.moves import winreg if directory is None: directory = win32FontDirectory() fontext = get_fontext_synonyms(fontext) key, items = None, {} for fontdir in MSFontDirectories: try: local = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, fontdir) except OSError: continue if not local: return list_fonts(directory, fontext) try: for j in range(winreg.QueryInfoKey(local)[1]): try: key, direc, any = winreg.EnumValue(local, j) if not is_string_like(direc): continue if not os.path.dirname(direc): direc = os.path.join(directory, direc) direc = direc.split('\0', 1)[0] if os.path.splitext(direc)[1][1:] in fontext: items[direc] = 1 except EnvironmentError: continue except WindowsError: continue except MemoryError: continue return list(six.iterkeys(items)) finally: winreg.CloseKey(local) return None 
0
Jun 05 '17 at 22:11
source share

This worked for me:

 sudo apt-get install libfreetype6-dev libxft-dev 
-one
Jun 29 '16 at 12:28
source share



All Articles