做这方面的安装最麻烦的就是一些库啊,路劲啊什么的,有时候太费事了,虽然很多时候可以直接扔给运维的同事去给我安装,但是,毕竟不是很方便,尤其是为了自己做个测试,就不用去麻烦人家和浪费人家时间了。
首先,安装需要的环境,Mysql 和 Python 就不说了,必备的东西。
主要是安装的MySQLdb ,可以去 sf.net 下载,具体地址是
http://sourceforge.net/projects/mysql-python/
root@localhost]# python setup.py build
Traceback (most recent call last):
File “setup.py”, line 5, in
from setuptools import setup, Extension
ImportError: No module named setuptools
1、下载一个文件
[root@localhost]# wget http://peak.telecommunity.com/dist/ez_setup.py
2、运行安装 setuptools:
[root@localhost]# python ez_setup.py
3、然后 build , install
PS:如果没外网
1、先运行 python ez_setup.py ,有个一个下载的文件。
如我这个版本:
http://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c11-py2.6.egg
2、去有公网的机器下载
http://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c11-py2.6.egg
然后传到与ez_setup.py 同一目录下,然后运行
[root@localhost]# python ez_setup.py
MySQL-python-1.2.3 # ./setup.py build
running build
running build_py
copying MySQLdb/release.py -> build/lib.linux-x86_64-2.6/MySQLdb
running build_ext
building ’_mysql’ extension
gcc -pthread -shared build/temp.linux-x86_64-2.6/_mysql.o -L/usr/local/mysql/lib/mysql -lmysqlclient_r -lz -lpthread -lcrypt -lnsl -lm -lpthread -o build/lib.linux-x86_64-2.6/_mysql.so
/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/bin/ld: cannot find -lmysqlclient_r
collect2: ld returned 1 exit status
error: command ’gcc’ failed with exit status 1
MySQL-python-1.2.3 # grep mysqlclient_r ./* -rn
setup_posix.py
mysqlclient_r 修改为 mysqlclient
elif enabled(options, ’threadsafe’):
libs = mysql_config(”libs”)
client = ”mysqlclient”
if not libs:
libs = mysql_config(”libs”)
client = ”mysqlclient”
MySQL-python-1.2.3 # ./setup.py build
MySQL-python-1.2.3 # ./setup.py install
安装完成!!!
补充记录下这个问题:
EnvironmentError: mysql_config not found
ln -s /usr/local/mysql/bin/mysql_config /usr/bin/mysql_config