解决CentOS下pip安装matplotlib报错:required packages can not be built

键盘旁的猫
键盘旁的猫
发布时间:2026-10-13 | 2人浏览过
原创

本文介绍在CentOS 6.5系统中使用pip安装matplotlib时遇到的“required packages can not be built”错误。该问题通常由缺少freetype和png系统依赖库引起。解决方法是通过yum手动安装freetype-devel和libpng-devel包,并提供了查询相关包名的命令参考。

使用pip命令安装matplotlib库

在64位CentOS 6.5系统中执行pip安装matplotlib时,系统返回报错信息:

* The following required packages can not be built:
            * freetype, png
error: Setup script exited with 1

出现此错误的原因是pip无法自动处理操作系统层面的依赖库,需要用户通过yum工具手动安装缺失的依赖项:

$ yum -y install freetype-devel libpng-devel

若不确定所需依赖库的具体包名,可通过以下命令进行查询:

$ yum search freetype | grep devel
  freetype-devel.i686 : FreeType development libraries and header files
  freetype-devel.x86_64 : FreeType development libraries and header files
$ yum search png | grep devel
  libpng-devel.i686 : Development tools for programs to manipulate PNG image
  libpng-devel.x86_64 : Development tools for programs to manipulate PNG image

参考资源:

matplotlib简介、安装指南及简单实例代码

Python numpy模块安装失败的简易解决方案汇总

总结

以上是关于解决pip安装matplotlib时报错“required packages can not be built”的全部内容,希望能为读者提供帮助。欢迎感兴趣的朋友继续浏览本站其他相关专题,如有任何疏漏,欢迎留言指正。感谢大家的支持!

本站声明

本文内容仅供参考,不代表本站观点。转载或引用请注明出处。如发现内容问题,请通过联系我们页面反馈。

Python 相关产品和应用

全部下载

专题列表