Home >Database >Mysql Tutorial >Python MySQL 库安装笔记

Python MySQL 库安装笔记

WBOY
WBOYOriginal
2016-06-07 16:31:57906browse

其实MySQL-python安装很简直,以前一直也没在意,今天发觉换了1.2.3新版本,ms蹦出很多问题来了。做个记录,防止以后有问题无处可查。 一般步骤是: 安装easy_install shell wget http://peak.telecommunity.com/dist/ez_setup.pyshell python ez_setup.py

其实MySQL-python安装很简直,以前一直也没在意,今天发觉换了1.2.3新版本,ms蹦出很多问题来了。 做个记录,防止以后有问题无处可查。

一般步骤是:

  1. 安装easy_install

shell > wget http://peak.telecommunity.com/dist/ez_setup.py
shell > python ez_setup.py

会自动根据本机的py版本选择对应的egg,安装完可以看到有/usr/bin/easy_install程序了

  1. 安装MySQL-python

shell > easy_install MySQL-python

到这里安装算是完成了,不过接下来测试就郁闷了。

在import MySQLdb出现了两个错误:

a). ImportError: libmysqlclient_r.so.15: cannot open shared object file: No such file or directory

这个错误一般解决比较简单,把路径加入到LD_LIBRARY_PATH即可,不过偶的现象比较强,因为没装MySQL,哈哈

b). ImportError: /lib/tls/libc.so.6: version `GLIBC_2.4' not found

解决这个错误的办法是不用easy_install了,直接下载MySQL-python-1.2.2.tar.gz包,然后就是三步走:

shell > tar zxvf MySQL-python-1.2.2.tar.gz
shell > cd MySQL-python-1.2.2
shell > python setup.py install
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn