關於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環境。

發佈了45 篇原創文章 · 獲贊 29 · 訪問量 18萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章