當使用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環境。