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

Python3.9.2安装matplotlib==2.0.2出现exit code:1错误求助

解决matplotlib==2.0.2安装时缺少freetype/png头文件的问题

你的问题核心是matplotlib编译安装时依赖的C/C++开发库缺失,不同操作系统的解决方式如下:

Debian/Ubuntu 系列

  • 先安装所需的开发依赖包:
    sudo apt-get install libfreetype6-dev libpng-dev
    
  • 重新执行matplotlib安装命令:
    pip install matplotlib==2.0.2
    

RHEL/CentOS/Fedora 系列

  • 安装对应开发依赖:
    # CentOS/RHEL
    sudo yum install freetype-devel libpng-devel
    
    # Fedora
    sudo dnf install freetype-devel libpng-devel
    
  • 重新执行安装:
    pip install matplotlib==2.0.2
    

macOS

  • 使用Homebrew安装依赖:
    brew install freetype libpng
    
  • 重新执行安装命令:
    pip install matplotlib==2.0.2
    

Windows

Windows下编译依赖配置繁琐,推荐直接安装预编译的wheel包:

  1. 下载适配Python3.9的matplotlib==2.0.2 wheel文件(注意匹配系统位数,如x64)
  2. 执行本地安装:
    pip install 你的wheel文件路径/matplotlib-2.0.2-cp39-none-win_amd64.whl
    

额外建议

matplotlib 2.0.2是较旧版本,官方对Python3.9的支持有限,若业务允许,建议安装支持Python3.9的更高版本(如>=3.3.0),可避免编译依赖问题:

pip install matplotlib>=3.3.0

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.14 09:15:49