centos7 安装MySQLdb-python 报错 解决方案

运行 pip install MySQL-python 报错:

Command python setup.py egg_info failed with error code 1 in 

继续试探

 yum install mysql-devel
 systemctl restart mariadb

之后再安装报错:

 Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-GMXMYA/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-VMNV_c-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /t
mp/pip-build-GMXMYA/MySQL-python/

继续找安装

 yum install MySQL-python 
 systemctl restart mariadb 

测试是否安装成功

 python 

进入 python之后 执行

>>> import MySQLdb
>>> print dir(MySQLdb)
['BINARY', 'Binary', 'Connect', 'Connection', 'DATE', 'DATETIME', 'DBAPISet', 'DataError', 'DatabaseError', 'Date', 'DateFromTicks', 'Error', 'FIELD_TYPE', 'IntegrityError', 'InterfaceError'
, 'InternalError', 'MySQLError', 'NULL', 'NUMBER', 'NotSupportedError', 'OperationalError', 'ProgrammingError', 'ROWID', 'STRING', 'TIME', 'TIMESTAMP', 'Time', 'TimeFromTicks', 'Timestamp', 
'TimestampFromTicks', 'Warning', '__all__', '__author__', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__', '__revision__', '__version__', '_mysql', 'apilevel', '
connect', 'connection', 'constants', 'debug', 'escape', 'escape_dict', 'escape_sequence', 'escape_string', 'get_client_info', 'paramstyle', 'release', 'result', 'server_end', 'server_init', 
'string_literal', 'test_DBAPISet_set_equality', 'test_DBAPISet_set_equality_membership', 'test_DBAPISet_set_inequality', 'test_DBAPISet_set_inequality_membership', 'thread_safe', 'threadsafe
ty', 'times', 'version_info']

因为系统用 yum install MySQLdb-python 来替代 pip install MySQLdb-python Author: [email protected] ~呵呵

你可能感兴趣的:(centos7 安装MySQLdb-python 报错 解决方案)