python
config_error
ai_generated
true
findfont: 未找到字体族 'Arial'。
findfont: Font family 'Arial' not found.
ID: python/matplotlib-findfont-cache-stale
80%修复率
87%置信度
0证据数
2024-08-11首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.x | active | — | — | — |
根因分析
请求的字体未安装在系统上,或安装新字体后 matplotlib 的字体缓存已过期。
English
The requested font is not installed on the system, or matplotlib's font cache is stale after installing a new font.
解决方案
-
90% 成功率
sudo apt-get install -y fonts-liberation rm -rf ~/.cache/matplotlib python -c "import matplotlib.font_manager as fm; fm._load_fontmanager(try_read_cache=False)"
-
95% 成功率
import matplotlib.pyplot as plt plt.rcParams['font.family'] = 'DejaVu Sans' # shipped with matplotlib
无效尝试
常见但无效的做法:
-
93% 失败
The font file is genuinely absent; naming it does not create it.
-
88% 失败
Upgrading matplotlib does not install OS-level font packages.