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

conda环境已装matplotlib但VSCode导入失败(DLL加载错误)

问题核心

导入matplotlib失败的根源并非matplotlib本身,而是其依赖的PIL(Pillow)库的_imaging模块DLL加载失败——matplotlib在初始化过程中调用了PIL的Image模块,进而触发该错误。

解决步骤
  • 检查当前环境的Pillow版本
    打开Anaconda Prompt,激活你的环境后执行:

    conda list pillow
    

    或者通过pip查看:

    pip list | findstr Pillow
    
  • 彻底卸载并重装适配Anaconda环境的Pillow

    1. 先强制卸载conda和pip中的Pillow:
      conda remove --force pillow
      pip uninstall -y pillow
      
    2. 用conda重新安装适配当前Python版本的Pillow(以Python3.10为例,推荐安装9.5.0版本):
      conda install pillow=9.5.0
      
  • 修复系统VC运行库缺失问题
    若重装Pillow后仍报错,大概率是系统缺少必要的VC
    运行库,安装Microsoft Visual C++ Redistributable for Visual Studio 2017-2022(选择与系统匹配的x64/x86版本)。

  • 确认VSCode环境配置并清除缓存

    1. 在VSCode左下角状态栏确认已选中正确的housingenv conda环境,若未选中则切换至该环境
    2. 删除项目目录下的__pycache__文件夹,重启VSCode
  • 尝试降级matplotlib版本
    若上述方法无效,可尝试降级matplotlib到更稳定的版本:

    conda remove --force matplotlib matplotlib-base matplotlib-inline
    conda install matplotlib=3.6.0
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.09 18:39:51