Centos7 "fatal error: Python.h: No such file or directory "commmand 'gcc' failed with exit status 1

使用pip安装matplotlib的时候出现了以下错误:

....
    _posixsubprocess.c:3:20: fatal error: Python.h: No such file or directory
     #include "Python.h"
                        ^
    compilation terminated.
    error: command 'gcc' failed with exit status 1
  1. fatal error: Python.h: No such file or directory
  2. command ‘gcc’ failed with exit status 1
    更新了gcc,还是不行,最后发现需要是缺少python-devel包,使用下面命令解决:
#centos
sudo yum -y install python-devel

#ubuntu
sudo apt-get install python-dev

#python3使用python3-dev

你可能感兴趣的:(error,linux,python)