一、pip install mysqlclient报MySQLdb/_mysql.c:46:20: fatal error: Python.h: No such file or directory错误
building 'MySQLdb._mysql' extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/MySQLdb
gcc -pthread -Wno-unused-result -Wsign-compare -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=(2,0,3,'final',0) -D__version__=2.0.3 -I/usr/local/mysql/include -I/usr/include/python3.6m -c MySQLdb/_mysql.c -o build/temp.linux-x86_64-3.6/MySQLdb/_mysql.o -std=c99
MySQLdb/_mysql.c:46:20: fatal error: Python.h: No such file or directory
#include "Python.h"
^
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-lfo3di25/mysqlclient/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-qvmjz7kj-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-lfo3di25/mysqlclient/
这个错误是因为没有安装python-devel,如果是pip3,则是因为没有安装python3-devel。
yum -y install python-devel
# 或者安装
yum -y install python3-devel