dns_extract.py:29: UserWarning: Glyph 19996 (\N{CJK UNIFIED IDEOGRAPH-4E1C}) missing from current font. plt.savefig('2.jpg') findfont: Generic family 'sans-serif' not found because none of the following families were found: SimHei
时间: 2023-12-28 11:31:47 浏览: 232
这个警告提示是由于你的当前字体中缺少了一个名为“\N{CJK UNIFIED IDEOGRAPH-4E1C}”的字符。而且,由于缺少了这个字符,无法找到适合的字体来显示它。
另外,警告中提到了“Generic family 'sans-serif' not found because none of the following families were found: SimHei”,这意味着在当前环境中找不到名为 SimHei 的字体,因此无法使用 sans-serif 字体族。
解决这个问题的一种方法是安装适合的字体来覆盖缺失的字符和字体族。你可以尝试安装 SimHei 字体来解决该问题。另外,你也可以尝试使用其他支持中文字符的字体来替代 SimHei。
另外,你也可以尝试在代码中指定其他可用的字体来保存图像,例如:
```python
import matplotlib.pyplot as plt
# 在保存图像之前指定字体
plt.rcParams['font.sans-serif'] = 'Arial'
# 绘制图像等操作...
# 保存图像
plt.savefig('2.jpg')
```
在这个例子中,我将字体设置为 Arial,你可以根据你的需求选择其他可用的字体。这样做可以避免使用缺失字符的字体,同时确保图像可以正常保存。
相关问题
/usr/lib/python3.10/tkinter/__init__.py:839: UserWarning: Glyph 20154 (\N{CJK UNIFIED IDEOGRAPH-4EBA}) missing from current font. func(*args) /usr/lib/python3.10/tkinter/__init__.py:839: UserWarning: Glyph 35780 (\N{CJK UNIFIED IDEOGRAPH-8BC4}) missing from current font. func(*args) /usr/lib/python3.10/tkinter/__init__.py:839: UserWarning: Glyph 20215 (\N{CJK UNIFIED IDEOGRAPH-4EF7}) missing from current font. func(*args)
这个警告是因为在当前字体中找不到指定的中文字符,分别是“人”、“评”和“货”字。这可能会导致在使用这些字符时无法正确显示,但一般情况下不会影响程序的功能。
你可以尝试更换字体,或者在代码中指定字体来解决这个问题。比如,在创建应用程序的时候,可以通过设置`font`参数来指定字体:
```python
import tkinter as tk
root = tk.Tk()
label = tk.Label(root, text="你好,世界!", font=("Arial", 12))
label.pack()
root.mainloop()
```
这里将标签的字体设置为Arial,大小为12。你可以根据需要选择其他字体和大小。
D:\python\python3.9.5\python.exe C:/Users/马斌/Desktop/NGSIM_data_processing/30s/x-y.py C:\Users\马斌\Desktop\NGSIM_data_processing\30s\x-y.py:12: MatplotlibDeprecationWarning: Support for FigureCanvases without a required_interactive_framework attribute was deprecated in Matplotlib 3.6 and will be removed two minor releases later. plt.plot(x, y) C:\Users\马斌\Desktop\NGSIM_data_processing\30s\x-y.py:20: MatplotlibDeprecationWarning: Support for FigureCanvases without a required_interactive_framework attribute was deprecated in Matplotlib 3.6 and will be removed two minor releases later. plt.show() D:\pyCharm\PyCharm 2020.2\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py:68: UserWarning: Glyph 36724 (\N{CJK UNIFIED IDEOGRAPH-8F74}) missing from current font. self.figure.tight_layout() D:\pyCharm\PyCharm 2020.2\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py:68: UserWarning: Glyph 25968 (\N{CJK UNIFIED IDEOGRAPH-6570}) missing from current font. self.figure.tight_layout() D:\pyCharm\PyCharm 2020.2\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py:68: UserWarning: Glyph 25454 (\N{CJK UNIFIED IDEOGRAPH-636E}) missing from current font. self.figure.tight_layout() D:\pyCharm\PyCharm 2020.2\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py:68: UserWarning: Glyph 20998 (\N{CJK UNIFIED IDEOGRAPH-5206}) missing from current font. self.figure.tight_layout() D:\pyCharm\PyCharm 2020.2\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py:68: UserWarning: Glyph 26512 (\N{CJK UNIFIED IDEOGRAPH-6790}) missing from current font. self.figure.tight_layout() D:\pyCharm\PyCharm 2020.2\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py:69: UserWarning: Glyph 36724 (\N{CJK UNIFIED IDEOGRAPH-8F74}) missing from current font. FigureCanvasAgg.draw(self) D:\pyCharm\PyCharm 2020.2\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py:69: UserWarning: Glyph 25968 (\N{CJK UNIFIED IDEOGRAPH-6570}) missing from current font. FigureCanvasAgg.draw(self) D:\pyCharm\PyCharm 2020.2\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py:69: UserWarning: Glyph 25454 (\N{CJK UNIFIED IDEOGRAPH-636E}) missing from current font. FigureCanvasAgg.draw(self) D:\pyCharm\PyCharm 2020.2\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py:69: UserWarning: Glyph 20998 (\N{CJK UNIFIED IDEOGRAPH-5206}) missing from current font. FigureCanvasAgg.draw(self) D:\pyCharm\PyCharm 2020.2\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py:69: UserWarning: Glyph 26512 (\N{CJK UNIFIED IDEOGRAPH-6790}) missing from current font. FigureCanvasAgg.draw(self)
这是一个警告信息,提示你的字体库中缺少一些字符,可能会导致图形显示不完全或乱码。你可以通过更改字体或安装缺失的字体来解决这个问题。同时,还有一个关于 FigureCanvas 的警告,这意味着 Matplotlib 将不再支持没有 required_interactive_framework 属性的 FigureCanvas,在未来的版本中可能会被删除。
阅读全文