关于Python安装模块出现error: command 'gcc' failed with exit status 1错误的解决方法

当使用pip install ###时,有时会出现如标题上的问题,我遇到的问题如下:

_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

这是我在安装matplotlib模块的时候出现的问题,重新安装了gcc等各种我能想到的,不过还是不行。到网上找了一下,说是其实安装一个对应的devel环境就可以了。 
举个例子,我这里报错是

#include "Python.h"
       ^
compilation terminated.
error: command 'gcc' failed with exit status 1

其实只要看include缺什么就行了,我缺的时Python.h,所以就安装以下python的devel环境就好

yum install python-devel
  •  

- 其他同类问题同理,对应下载相应的devel环境。

猜你喜欢

转载自blog.csdn.net/xuezhangjun0121/article/details/81083287