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

Matplotlib无法加载已安装PIL模块,打印rcParams报错求助

解决Anaconda环境中Matplotlib导入时PIL _imaging DLL加载失败的问题

试试下面这些步骤排查解决:

  • 清理并重新安装依赖(换conda-forge频道)
    先彻底移除现有冲突的包,再从更兼容的频道重新安装:

    conda remove --force pillow matplotlib
    conda clean --all
    conda install -c conda-forge pillow matplotlib
    
  • 检查并安装VC++运行库
    _imaging.dll加载失败大概率是系统缺少对应的Visual C++ Redistributable运行库,安装适配Python 3.10的版本(推荐Microsoft Visual C++ Redistributable 2019或2022),安装后重启环境再测试。

  • 单独验证Pillow是否正常
    先排除Pillow本身的问题,运行以下命令测试:

    python -c "from PIL import Image; print(Image.__version__)"
    

    如果这个命令报错,说明Pillow的安装本身有问题,继续排查系统环境;如果能正常运行,那问题可能出在Matplotlib和Pillow的版本兼容上。

  • 升级Matplotlib到兼容版本
    你当前用的Matplotlib 3.5.3对Python 3.10的兼容性不如后续版本,尝试升级到3.7.x系列:

    conda install matplotlib=3.7.1
    
  • 创建全新Anaconda环境
    如果以上都没用,大概率是现有环境的依赖链混乱了,直接新建干净环境测试:

    conda create -n mpl_test_env python=3.10
    conda activate mpl_test_env
    conda install matplotlib pillow
    

    然后在这个环境里运行你的代码,看是否还会报错。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.08 05:42:07