matplotlib taking time when being imported
I just upgraded to the latest stable release of matplotlib
(1.5.1) and everytime 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 stalls for a few seconds.
Is this the expected behaviour? Was it the same also before, but just without the printed message?
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
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/*
I ran the python code using sudo just once, and it resolved the warning for me. Now it runs faster. Running without sudo gives no warning at all.
Cheers
I ran the python code w. sudo and it cured it...my guess was that there wasn't permission to write that table... good luck!