gpt4 book ai didi

python - ValueError : Failed to find font DejaVu Sans:style=normal:variant=normal:weight=normal. ..并且回退到默认字体被禁用

转载 作者:行者123 更新时间:2023-12-03 08:09:43 40 4
gpt4 key购买 nike

我在尝试绘制一些数据时收到此错误:

findfont: Font family ['STIXGeneral'] not found. Falling back to DejaVu Sans.
Traceback (most recent call last):
File "F:/Python/compairing-epsilons/main.py", line 71, in <module>
c_1=Bandit.experiment(m1,m2,m3 ,0.1 ,100000)
File "F:/Python/compairing-epsilons/main.py", line 62, in experiment
plt.show()
File "F:\Python\compairing-epsilons\lib\site-packages\matplotlib\pyplot.py", line 368, in show
return _backend_mod.show(*args, **kwargs)
File "E:\MyProgramFiles\JetBrains\PyCharm 2020.1\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py", line 27, in __call__
manager.show(**kwargs)
File "E:\MyProgramFiles\JetBrains\PyCharm 2020.1\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py", line 99, in show
self.canvas.show()
File "E:\MyProgramFiles\JetBrains\PyCharm 2020.1\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py", line 64, in show
self.figure.tight_layout()
File "F:\Python\compairing-epsilons\lib\site-packages\matplotlib\figure.py", line 3199, in tight_layout
pad=pad, h_pad=h_pad, w_pad=w_pad, rect=rect)
File "F:\Python\compairing-epsilons\lib\site-packages\matplotlib\tight_layout.py", line 325, in get_tight_layout_figure
pad=pad, h_pad=h_pad, w_pad=w_pad)
File "F:\Python\compairing-epsilons\lib\site-packages\matplotlib\tight_layout.py", line 82, in _auto_adjust_subplotpars
bb += [ax.get_tightbbox(renderer, for_layout_only=True)]
File "F:\Python\compairing-epsilons\lib\site-packages\matplotlib\axes\_base.py", line 4620, in get_tightbbox
renderer, for_layout_only=for_layout_only)
File "F:\Python\compairing-epsilons\lib\site-packages\matplotlib\axis.py", line 1105, in get_tightbbox
self._update_label_position(renderer)
File "F:\Python\compairing-epsilons\lib\site-packages\matplotlib\axis.py", line 2083, in _update_label_position
bboxes, bboxes2 = self._get_tick_boxes_siblings(renderer=renderer)
File "F:\Python\compairing-epsilons\lib\site-packages\matplotlib\axis.py", line 1881, in _get_tick_boxes_siblings
tlb, tlb2 = axis._get_tick_bboxes(ticks_to_draw, renderer)
File "F:\Python\compairing-epsilons\lib\site-packages\matplotlib\axis.py", line 1086, in _get_tick_bboxes
for tick in ticks if tick.label1.get_visible()],
File "F:\Python\compairing-epsilons\lib\site-packages\matplotlib\axis.py", line 1086, in <listcomp>
for tick in ticks if tick.label1.get_visible()],
File "F:\Python\compairing-epsilons\lib\site-packages\matplotlib\text.py", line 910, in get_window_extent
bbox, info, descent = self._get_layout(self._renderer)
File "F:\Python\compairing-epsilons\lib\site-packages\matplotlib\text.py", line 318, in _get_layout
clean_line, self._fontproperties, ismath=ismath)
File "F:\Python\compairing-epsilons\lib\site-packages\matplotlib\backends\backend_agg.py", line 265, in get_text_width_height_descent
self.mathtext_parser.parse(s, self.dpi, prop)
File "F:\Python\compairing-epsilons\lib\site-packages\matplotlib\mathtext.py", line 435, in parse
return self._parse_cached(s, dpi, prop, _force_standard_ps_fonts)
File "F:\Python\compairing-epsilons\lib\site-packages\matplotlib\mathtext.py", line 447, in _parse_cached
font_output = fontset_class(prop, backend)
File "F:\Python\compairing-epsilons\lib\site-packages\matplotlib\_mathtext.py", line 577, in __init__
self.cm_fallback = StixSansFonts(*args, **kwargs)
File "F:\Python\compairing-epsilons\lib\site-packages\matplotlib\_mathtext.py", line 681, in __init__
fullpath = findfont(name)
File "F:\Python\compairing-epsilons\lib\site-packages\matplotlib\font_manager.py", line 1309, in findfont
rc_params)
File "F:\Python\compairing-epsilons\lib\site-packages\matplotlib\font_manager.py", line 1362, in _findfont_cached
fallback_to_default=False)
File "F:\Python\compairing-epsilons\lib\site-packages\matplotlib\font_manager.py", line 1309, in findfont
rc_params)
File "F:\Python\compairing-epsilons\lib\site-packages\matplotlib\font_manager.py", line 1364, in _findfont_cached
raise ValueError(f"Failed to find font {prop}, and fallback "
ValueError: Failed to find font DejaVu Sans:style=normal:variant=normal:weight=normal:stretch=normal:size=10.0, and fallback to the default font was disabled

Process finished with exit code 1

在绘图时,我的其他项目没有出现此字体错误。如何解决错误?

最佳答案

基于此github issue尝试删除 matplotlib 缓存目录中的所有内容

import matplotlib
print(matplotlib.get_cachedir()) # should return something like ~/.matplotlib

导航到该目录并删除字体文件,该文件类似于 fontlist-v330.json

关于python - ValueError : Failed to find font DejaVu Sans:style=normal:variant=normal:weight=normal. ..并且回退到默认字体被禁用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71176394/

40 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com