如何解决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('
', '
');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:
看完上述内容,你们掌握如何解决centos7安装MySQLdb-python报错的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注亿速云行业资讯频道,感谢各位的阅读!