我是靠谱客的博主 单纯过客,这篇文章主要介绍Linux python2安装mysql-python遇到的坑,现在分享给大家,希望可以做个参考。

Linux python2安装MySQLdb遇到的坑

首先

pip install MySQL-python

遇到报错 提示:EnvironmentError: mysql_config not found

网上搜索资料提示这是因为本机需要安装llibmysqlclient-dev

执行

yum install libmysqlclient-dev

但是我的即使通过官网下载rpm文件,添加了mysql comunity的源之后依然找不到该文件。

所以我直接在本机安装了mysql:

yum install mysql-server

完成后再次执行mysql-python,提示:"command ‘gcc’ failed with exit status 1

解决方法为安装一下库:

yum install gcc libffi-devel python-devel openssl-devel -y

然后还是报错:"command ‘gcc’ failed with exit status 1

通过观察发现上面有提示是MySQLdb install error - _mysql.c:44:23: error: my_config.h: No such file or directory,即缺少my_config.h

所以使用:

sudo wget https://raw.githubusercontent.com/paulfitz/mysql-connector-c/master/include/my_config.h -O /usr/include/mysql/my_config.h

重复pip 操作

pip install MySQL-python

安装成功!

最后

以上就是单纯过客最近收集整理的关于Linux python2安装mysql-python遇到的坑的全部内容,更多相关Linux内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(143)

评论列表共有 0 条评论

立即
投稿
返回
顶部