在Python安装MySQLdb模块遇见的问题

安装python2.7的MySQLdb模块时遇见如下问题:
[root@mycat-1 MySQL-python-1.2.3b1]# python setup.py build
running build
running build_py
copying MySQLdb/release.py -> build/lib.linux-x86_64-2.7/MySQLdb
running build_ext
building ‘_mysql’ extension
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-strong –param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -Dversion_info=(1,2,3,’beta’,1) -D__version__=1.2.3b1 -I/home/mycat/mysql_5717/include -I/usr/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o -fabi-version=2 -fno-omit-frame-pointer
_mysql.c:35:23: fatal error: my_config.h: No such file or directory
#include “my_config.h”
^
compilation terminated.

error: command ‘gcc’ failed with exit status 1

看网上说要安装mysql-devel:

yum install -y mysql-devel

但是安装之后还是报同样的错误
执行:which mysql_config

[root@mycat-1 MySQL-python-1.2.3b1]# which mysql_config
/home/mycat/mysql_5717/bin/mysql_config

我感觉我发现问题了,可能是我yum安装mysql-devel、mysql的版本与PATH路径下的mysql_config版本有冲突
修改PATH中mysql_config路径,改外/usr/bin/mysql_conifg之后,再进行安装,成功了。
tips:还可以通过修改setup_posix.py中mysql_config.path直接改为/usr/local/mysql_config来解决版本冲突问题。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值