1. 程式人生 > >mysql-python 安裝

mysql-python 安裝

some err 提示 share install director down 一個 sta

[[email protected] ~]# [[email protected] ~]# [[email protected] ~]# gcc -v 查看是否安裝gcc 若報錯則未安裝

[[email protected] ~]# yum -y install gcc 安裝gcc

[[email protected] ~]# wget http://downloads.sourceforge.net/project/mysql-python/mysql-python-test/1.2.4b4/MySQL-python-1.2.4b4.tar.gz?use_mirror=ncu

下載軟件包

[[email protected] ~]# tar zxvf MySQL-python-1.2.4b4.tar.gz cd MySQL-python-1.2.4b4 解壓軟件包

解壓包復制到 /usr/local/src/ 下

進入 /usr/local/src/MySQL-python-1.2.4b4

[[email protected] MySQL-python-1.2.4b4]# find / -name mysql_config 查看 mysql_config 文件位置 /usr/local/mysql/bin/mysql_config [[email protected]
/* */ ~]# vim site.cfg 進入site.cfg 配置文件進行修改

# embedded: link against the embedded server library # threadsafe: use the threadsafe client # static: link against a static library (probably required for embedded)

embedded = False

threadsafe = False (改為False)

static = False

# The path to mysql_config. # Only use this if mysql_config is not on your PATH, or you have some weird # setup that requires it.

mysql_config = /usr/local/mysql/bin/mysql_config (前面的#去掉,並把路徑更改正確)

最後進行安裝:

# python setup.py build
# python setup.py install 完畢之後 進入python >>> import MySQLdb 若出錯: Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "MySQLdb/__init__.py", line 19, in <module>
import _mysql
ImportError: libmysqlclient.so.20: cannot open shared object file: No such file or directory 根據最後提示,應該是找不著一個交libmysqlclient.so.20的文件,於是到mysql安裝目錄裏找到這個文件並且做一個軟連接到/usr/lib [[email protected] lib]# ln -s /usr/local/mysql/lib/libmysqlclient.so.20 /usr/lib/libmysqlclient.so.20 再次導入模塊就成功了

mysql-python 安裝