matplotlib taking time when being imported

Confirmed Hugo's approach works for Ubuntu 14.04 LTS/matplotlib 1.5.1:

  • deleted ~/.cache/matplotlib/fontList.cache
  • ran code, again the warning was issued (assumption: is rebuilding the cache correctly)
  • ran code again, no more warning (finally)

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

  • remove the cache files from this directory as well: ~/.cache/fontconfig (as per tom's suggestion)
    rm -rvf ~/.cache/fontconfig/*
  • also removed .cache files in ~/.matplotlib (as per Hugo's suggestion)
    rm -rvf ~/.matplotlib/*

As tom suggested in the comment above, deleting the files:

fontList.cache
fontList.py3k.cache 
tex.cache 

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

`~/.matplotlib`

EDITED

A couple of days ago the message appeared again, I deleted the files in the locations mention above without any success. I found that as suggested here by T Mudau there's an extra location with text cache files is: ~/.cache/fontconfig