Python2.7安装MySQLdb
短信预约 -IT技能 免费直播动态提醒
安装步骤如下:
1、wget http://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.3/MySQL-python-1.2.3.tar.gz
2、tar zxvf MySQL-python-1.2.3.tar.gz
3、cd MySQL-python-1.2.3
4、python setup.py build (这里有可能会报错如下)
[root@VM_162_135_centos MySQL-python-1.2.3]# python setup.py build
sh: mysql_config: command not found
Traceback (most recent call last):
File "setup.py", line 15, in <module>
metadata, options = get_config()
File "/root/MySQL-python-1.2.3/setup_posix.py", line 43, in get_config
libs = mysql_config("libs_r")
File "/root/MySQL-python-1.2.3/setup_posix.py", line 24, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
解决办法:
a)yum install mysql-devel libmysqlclient-dev
b)
[root@VM_162_135_centos ~]# find / -name mysql_config
/etc/alternatives/mysql_config
/var/lib/alternatives/mysql_config
/usr/bin/mysql_config
/usr/lib64/mysql/mysql_config
c)修改/root/MySQL-python-1.2.3/setup_posix.py文件,将26行的mysql_config.path = “mysql_config” 修改为:
mysql_config.path = “/usr/bin/mysql_config”,并保存
d)继续执行python setup.py build
5、python setup.py install
到此安装完成!
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341