I’m using Matplotlib 3.5.1 with Python 3.10.1 on Linux. I have lately observed that the import time is noticeably very slow (~3.6s).
$ time python -c 'import matplotlib'
python -c 'import matplotlib' 1.14s user 0.09s system 99% cpu 1.233 total
$ time python -c 'import matplotlib.pyplot'
python -c 'import matplotlib.pyplot' 3.50s user 0.10s system 99% cpu 3.608 total
I have search for similar problem on the internet, and found python - Extremely slow import of matplotlib afm - Stack Overflow and the GitHub issue, #3655 (I’m a new user in this Discourse, and so can only post 2 links). But clearing ~/.cache/matplotlib
has no effect.
I also tried matplotlib.font_manager._rebuild()
, but it error-ed out with module 'matplotlib' has no attribute 'font_manager'
(probably because this is an outdated API?).
I wonder if it because of something else?
Here is my importtime
log: matplotlib 3.5.1 on Python 3.10.1 on Linux importtime log · GitHub
pyparsing.helpers
, matplotlib.collections
, matplotlib.patches
seem to be significant.