CentOS7上 pip install MySQL-python 安装失败(error: command 'gcc' failed with exit status 1)的解决办法

(pk_env) [dechao@s97-74-237-68 ~]$ pip install MySQL-python                
Collecting MySQL-python
 Using cached MySQL-python-1.2.5.zip
Building wheels for collected packages: MySQL-python
 Running setup.py bdist_wheel for MySQL-python ... error
 Complete output from command /home/dechao/pk_env/bin/python2.7 -u -c "import setuptools, tokenize;_
_file__='/tmp/pip-build-VCoMlt/MySQL-python/setup.py';f=getattr(tokenize, 'open', open)(__file__);cod
e=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp
/tmp1M4ik7pip-wheel- --python-tag cp27:
 running bdist_wheel
 running build
 running build_py
 creating build
 creating build/lib.linux-x86_64-2.7
 copying _mysql_exceptions.py -> build/lib.linux-x86_64-2.7
 creating build/lib.linux-x86_64-2.7/MySQLdb
 copying MySQLdb/__init__.py -> build/lib.linux-x86_64-2.7/MySQLdb
 copying MySQLdb/converters.py -> build/lib.linux-x86_64-2.7/MySQLdb
 copying MySQLdb/connections.py -> build/lib.linux-x86_64-2.7/MySQLdb
 copying MySQLdb/cursors.py -> build/lib.linux-x86_64-2.7/MySQLdb
 copying MySQLdb/release.py -> build/lib.linux-x86_64-2.7/MySQLdb
 copying MySQLdb/times.py -> build/lib.linux-x86_64-2.7/MySQLdb
 creating build/lib.linux-x86_64-2.7/MySQLdb/constants
 copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
 copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
 copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
 copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
 copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
 copying MySQLdb/constants/REFRESH.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
 copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
 running build_ext
 building '_mysql' extension
 creating build/temp.linux-x86_64-2.7
 gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-p
rotector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fP
IC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong
--param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC
-Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/include/mysql -I/usr/include/python2.7 -
c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o
 _mysql.c:29:20: 致命错误:Python.h:没有那个文件或目录
  #include "Python.h"
                     ^
 编译中断。
 error: command 'gcc' failed with exit status 1
  
 ----------------------------------------
 Failed building wheel for MySQL-python
 Running setup.py clean for MySQL-python
Failed to build MySQL-python
Installing collected packages: MySQL-python
 Running setup.py install for MySQL-python ... error
   Complete output from command /home/dechao/pk_env/bin/python2.7 -u -c "import setuptools, tokenize
;__file__='/tmp/pip-build-VCoMlt/MySQL-python/setup.py';f=getattr(tokenize, 'open', open)(__file__);c
ode=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record
/tmp/pip-OAwTQG-record/install-record.txt --single-version-externally-managed --compile --install-hea
ders /home/dechao/pk_env/include/site/python2.7/MySQL-python:
   running install
   running build
   running build_py
   creating build
   creating build/lib.linux-x86_64-2.7
   copying _mysql_exceptions.py -> build/lib.linux-x86_64-2.7
   creating build/lib.linux-x86_64-2.7/MySQLdb
   copying MySQLdb/__init__.py -> build/lib.linux-x86_64-2.7/MySQLdb
   copying MySQLdb/converters.py -> build/lib.linux-x86_64-2.7/MySQLdb
   copying MySQLdb/connections.py -> build/lib.linux-x86_64-2.7/MySQLdb
   copying MySQLdb/cursors.py -> build/lib.linux-x86_64-2.7/MySQLdb
   copying MySQLdb/release.py -> build/lib.linux-x86_64-2.7/MySQLdb
   copying MySQLdb/times.py -> build/lib.linux-x86_64-2.7/MySQLdb
   creating build/lib.linux-x86_64-2.7/MySQLdb/constants
   copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
   copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
   copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
   copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
   copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
   copying MySQLdb/constants/REFRESH.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
   copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
   running build_ext
   building '_mysql' extension
   creating build/temp.linux-x86_64-2.7
   gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack
-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -
fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-stron
g --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fP
IC -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/include/mysql -I/usr/include/python2.7
-c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o
   _mysql.c:29:20: 致命错误:Python.h:没有那个文件或目录
    #include "Python.h"
                       ^
   编译中断。
   error: command 'gcc' failed with exit status 1
    
   ----------------------------------------
Command "/home/dechao/pk_env/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/tmp/pip-buil
d-VCoMlt/MySQL-python/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r
\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-OAwTQG-record/i
nstall-record.txt --single-version-externally-managed --compile --install-headers /home/dechao/pk_env
/include/site/python2.7/MySQL-python" failed with error code 1 in /tmp/pip-build-VCoMlt/MySQL-python/

---------------------------- 安装 python-devel

(pk_env) [dechao@s97-74-237-68 ~]$ sudo yum install python-devel

----------------------------  

之后 pip instal MySQL-python 成功




你可能感兴趣的:(Python,学习杂记)