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

Matplotlib报错AttributeError: module 'matplotlib.cbook' has no attribute '_Stack'求助

解决Matplotlib版本冲突引发的AttributeError: module 'matplotlib.cbook' has no attribute '_Stack'问题

1. 彻底清理环境中的Matplotlib相关包

先激活你的conda环境(把your_env换成实际环境名称):

conda activate your_env

接着卸载所有Matplotlib相关包:

pip uninstall -y matplotlib
conda uninstall -y matplotlib matplotlib-base

检查是否清理干净,执行以下命令确认无残留:

pip list | grep matplotlib
conda list | grep matplotlib

如果还有残留,用pip show matplotlib查看安装路径,手动删除对应文件夹。

2. 用conda重新安装匹配版本的Matplotlib

保持环境激活状态,执行安装命令:

conda install matplotlib

conda会自动安装配套的matplotlib和matplotlib-base,确保版本兼容。

3. 验证修复效果

打开Python终端测试:

import matplotlib.pyplot as plt
plt.plot([1,2,3])
plt.show()

能正常弹出绘图窗口就说明问题解决了。

注意事项

  • 别在conda环境里混用pip和conda装Matplotlib这类依赖复杂的库,很容易搞出版本冲突。
  • 要是需要用Seaborn,直接用conda install seaborn安装,它会自动匹配兼容的Matplotlib版本。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.06 19:14:53