C:\Program Files\JetBrains\PyCharm 2021.3\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py:68: UserWarning: Glyph 21697 (\N{CJK UNIFIED IDEOGRAPH-54C1}) missing from current font. FigureCanvasAgg.draw(self怎么解决
时间: 2023-06-30 21:19:25 浏览: 71
这个警告提示了一个问题:在当前环境中找不到“\N{CJK UNIFIED IDEOGRAPH-54C1}”这个字符的字形信息,也就是“产品”这个汉字的字形信息。因此,当 matplotlib 绘制图形时,无法正确显示该字符。
要解决这个问题,你可以通过以下步骤进行操作:
1. 安装中文字体库,例如 SimHei 字体库。
2. 在代码中进行如下设置:
```python
import matplotlib
matplotlib.rcParams['font.family'] = 'sans-serif'
matplotlib.rcParams['font.sans-serif'] = ['SimHei']
```
这样,就可以在 matplotlib 中使用 SimHei 字体来显示中文字符。
3. 如果你仍然收到警告,可以尝试重新生成 matplotlib 的字体缓存:
```python
import matplotlib.font_manager as fm
fm._rebuild()
```
这会重新生成 matplotlib 的字体缓存,从而确保 matplotlib 能够正确地加载所有字体。
通过以上操作,你应该可以解决该警告问题。
相关问题
E:\visualization\analysis\1.py:80: 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() C:\Program Files\JetBrains\PyCharm 2021.3\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py:68: UserWarning: Glyph 21508 (\N{CJK UNIFIED IDEOGRAPH-5404}) missing from current font. FigureCanvasAgg.draw(self) C:\Program Files\JetBrains\PyCharm 2021.3\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py:68: UserWarning: Glyph 20010 (\N{CJK UNIFIED IDEOGRAPH-4E2A}) missing from current font. FigureCanvasAgg.draw(self) C:\Program Files\JetBrains\PyCharm 2021.3\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py:68: UserWarning: Glyph 26376 (\N{CJK UNIFIED IDEOGRAPH-6708}) missing from current font. FigureCanvasAgg.draw(self) C:\Program Files\JetBrains\PyCharm 2021.3\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py:68: UserWarning: Glyph 20221 (\N{CJK UNIFIED IDEOGRAPH-4EFD}) missing from current font. FigureCanvasAgg.draw(self) C:\Program Files\JetBrains\PyCharm 2021.3\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py:68: UserWarning: Glyph 30340 (\N{CJK UNIFIED IDEOGRAPH-7684}) missing from current font. FigureCanvasAgg.draw(self) C:\Program Files\JetBrains\PyCharm 2021.3\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py:68: UserWarning: Glyph 38144 (\N{CJK UNIFIED IDEOGRAPH-9500}) missing from current font. FigureCanvasAgg.draw(self) C:\Program Files\JetBrains\PyCharm 2021.3\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py:68: UserWarning: Glyph 21806 (\N{CJK UNIFIED IDEOGRAPH-552E}) missing from current font. FigureCanvasAgg.draw(self) C:\Program Files\JetBrains\PyCharm 2021.3\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py:68: UserWarning: Glyph 24773 (\N{CJK UNIFIED IDEOGRAPH-60C5}) missing from current font. FigureCanvasAgg.draw(self) C:\Program Files\JetBrains\PyCharm 2021.3\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py:68: UserWarning: Glyph 20917 (\N{CJK UNIFIED IDEOGRAPH-51B5}) missing from current font. FigureCanvasAgg.draw(self) C:\Program Files\JetBrains\PyCharm 2021.3\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py:68: UserWarning: Glyph 36135 (\N{CJK UNIFIED IDEOGRAPH-8D27}) missing from current font. FigureCanvasAgg.draw(self) C:\Program Files\JetBrains\PyCharm 2021.3\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py:68: UserWarning: Glyph 21697 (\N{CJK UNIFIED IDEOGRAPH-54C1}) missing from current font. FigureCanvasAgg.draw(self) Process finished with exit code 0
这是一些Matplotlib的警告信息。其中第一条警告表示,Matplotlib 3.6版本开始不再支持没有“required_interactive_framework”属性的FigureCanvases,这个属性用于指定绘图所需的交互式框架。如果你的代码中使用了这样的FigureCanvas,建议更新Matplotlib版本或修改代码以使用最新的FigureCanvas。
其他的警告则是指出当前字体中缺少一些中文字符,这可能会影响绘图结果的显示效果。可以通过更换字体或安装支持中文字符的字体来解决这个问题。
这些警告信息并不会影响代码的运行,只是提醒你可能需要注意一些绘图的细节问题。建议在代码中加入以下语句来禁止警告的输出:
```
import warnings
warnings.filterwarnings("ignore")
```
解释下这段报错内容C:\Program Files\JetBrains\PyCharm 2021.3.1\plugins\python\helpers\pycharm\_jb_pytest_runner.py:8: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html from pkg_resources import
这段报错内容是在运行 PyCharm 的 pytest_runner.py 文件时出现的。报错信息指出,使用 pkg_resources 模块的方式已被标记为过时(DeprecationWarning)并且不再推荐使用。pkg_resources 是一个用于处理 Python 包和资源的工具,但现在官方推荐使用 setuptools 库来代替它。
建议你查看给出的链接,了解如何使用 setuptools 来替代 pkg_resources,以解决这个问题。