You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PyCharm中Jupyter显示Matplotlib图表后文本输出消失问题求助

PyCharm 2024.1 Jupyter Notebook中Matplotlib图表后打印文本空白的解决办法

问题现象

  • 在PyCharm 2024.1内置的Jupyter Notebook环境中,调用display(fig)或plt.show()展示Matplotlib图表后,后续的print()输出仅显示空白块
  • 图表展示前的所有打印内容显示正常;注释掉图表展示代码后,文本输出恢复正常
  • 同一Notebook在浏览器中打开无异常,重启内核无法解决问题
  • 环境版本:matplotlib v3.7.0,matplotlib-inline v0.1.6

可能的解决方法

  • 强制指定Matplotlib inline后端:在Notebook开头添加以下代码,确保使用正确的inline后端渲染图表:

    import matplotlib
    matplotlib.use('module://matplotlib_inline.backend_inline')
    
  • 升级matplotlib-inline版本:当前使用的0.1.6版本较旧,可能存在与PyCharm 2024.1的兼容性问题,执行以下命令升级:

    pip install --upgrade matplotlib-inline
    
  • 关闭PyCharm的图表工具窗口预览:打开PyCharm设置(File → Settings),进入Tools → Python Scientific,取消勾选Show plots in tool window,重启PyCharm后重试。

  • 临时回退PyCharm版本:若上述方法均无效,可暂时回退到PyCharm 2023.3版本,等待JetBrains修复该兼容性bug。

内容的提问来源于stack exchange,提问作者Adam Knirsch

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.26 08:29:57