1.安装Python,安装的Python的版本是: 2.4.2
2.安装Mysql在/usr/local/Mysql中
3.获取MySQLdb库
1). 从: http://sourceforge.net/projects/mysql-python 下载MySQLdb库: MySQL-python-1.2.2.tar.gz
把这个库放在: /usr/local/MySQL-python-1.2.2.tar.gz,解压到文件夹: /usr/local/MySQL-python-1.2.2
进入到这个目录,执行安装: python setup.py bulid ,当执行这个语句的时候,出现了一个问题,提示没有setuptools,因此必须先下载这个工具。
2). 从: http://pypi.python.org/pypi/setu ... ac-os-x-linux-other,下载:setuptools-0.6c8-py2.4.egg
把这个文件放到:/usr/local/setuptools-0.6c8-py2.4.egg中,然后执行: sh setuptools-0.6c8-py2.4.egg
3). 通过pyton setup.py build去编译
$ python setup.py build
installsh: line 1: mysql_config: command not found
Traceback (most recent call last):
File "setup.py", line 16, in ?
metadata, options = get_config()
File "/Users/farocco/MySQL-python-1.2.2/setup_posix.py", line 43, in
get_config
libs = mysql_config("libs_r")
File "/Users/farocco/MySQL-python-1.2.2/setup_posix.py", line 24, in
mysql_config
raise EnvironmentError, "%s not found" % mysql_config.path
EnvironmentError: mysql_config not found
按照mysql-python的文档一步步来做,仍然会遇到这种问题,其实原因出在mysql_config上。首先需要定位到本机的mysql_config,此文件处在mysql安装位置的bin目录下(假设Mysql安装在/data/mysql下,
则路径为/data/mysql/bin/mysql_config)
修改setup_posix.py文件,在26行显示地设定mysql_config:mysql_config.path = "/data/mysql/bin/mysql_config"
最后就可以通过python setup.py bulid,python setup.py install去安装MySQLdb了
4. 安装完后启动Python,导入MySQLdb库时,出现一个提示信息:ImportError: libmysqlclient_r.so.15: cannot open shared
object,为了解决这个问题,从MySql的安装路径:/usr/local/mysql/lib中拷贝libmysqlclient_r.so.15到/usr/lib目录下即可。
2.安装Mysql在/usr/local/Mysql中
3.获取MySQLdb库
1). 从: http://sourceforge.net/projects/mysql-python 下载MySQLdb库: MySQL-python-1.2.2.tar.gz
把这个库放在: /usr/local/MySQL-python-1.2.2.tar.gz,解压到文件夹: /usr/local/MySQL-python-1.2.2
进入到这个目录,执行安装: python setup.py bulid ,当执行这个语句的时候,出现了一个问题,提示没有setuptools,因此必须先下载这个工具。
2). 从: http://pypi.python.org/pypi/setu ... ac-os-x-linux-other,下载:setuptools-0.6c8-py2.4.egg
把这个文件放到:/usr/local/setuptools-0.6c8-py2.4.egg中,然后执行: sh setuptools-0.6c8-py2.4.egg
3). 通过pyton setup.py build去编译
$ python setup.py build
installsh: line 1: mysql_config: command not found
Traceback (most recent call last):
File "setup.py", line 16, in ?
metadata, options = get_config()
File "/Users/farocco/MySQL-python-1.2.2/setup_posix.py", line 43, in
get_config
libs = mysql_config("libs_r")
File "/Users/farocco/MySQL-python-1.2.2/setup_posix.py", line 24, in
mysql_config
raise EnvironmentError, "%s not found" % mysql_config.path
EnvironmentError: mysql_config not found
按照mysql-python的文档一步步来做,仍然会遇到这种问题,其实原因出在mysql_config上。首先需要定位到本机的mysql_config,此文件处在mysql安装位置的bin目录下(假设Mysql安装在/data/mysql下,
则路径为/data/mysql/bin/mysql_config)
修改setup_posix.py文件,在26行显示地设定mysql_config:mysql_config.path = "/data/mysql/bin/mysql_config"
最后就可以通过python setup.py bulid,python setup.py install去安装MySQLdb了
4. 安装完后启动Python,导入MySQLdb库时,出现一个提示信息:ImportError: libmysqlclient_r.so.15: cannot open shared
object,为了解决这个问题,从MySql的安装路径:/usr/local/mysql/lib中拷贝libmysqlclient_r.so.15到/usr/lib目录下即可。