Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 738
Ricky Robinson Avatar asked Jan 13 '16 15:01

Ricky Robinson


People also ask

Why does matplotlib take so long?

It's your bottleneck. In your case, you don't need to re-draw things like the axes boundaries, tick labels, etc. 2) In your case, there are a lot of subplots with a lot of tick labels. These take a long time to draw.

Why is matplotlib not importing?

The error is caused because of the following reasons, check them out: Make sure that the version of matplotlib you are installing is compaitible with your python version installed. If the python installed is 64 bits version with matplotlib is 32bits. Make sure they are the same.

Does matplotlib work in idle?

Download the “Install Matplotlib (for Mac)” file from my web site, and double-click it to run it. Test your installation. Start IDLE, type “import matplotlib”, and confirm that this command completes without an error.


2 Answers

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

like image 163
Hugo Avatar answered Oct 09 '22 09:10

Hugo


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)
like image 22
Bill Gale Avatar answered Oct 09 '22 11:10

Bill Gale