如果是Linux下装MySQLDB的话,需要安装不少的包 python-mysqldb ,python-all-dev , libmysqlclient15-dev , zlib1g-dev 其中特别注意: 安装python-dev时候==>
yum install python-devel
步骤:
A.下载:wget http://nchc.dl.sourceforge.net/project/mysql-python/mysql-python/1.2.3/MySQL-python-1.2.3.tar.gz
B.
$ tar xfz MySQL-python-1.2.3.tar.gz
$ cd MySQL-python-1.2.3
$ cd MySQL-python-1.2.3
$whereis mysql_config
mysql_config: /usr/bin/mysql_config
$ vim site.cfg
修改mysql_config为mysql配置文件的路径 /usr/bin/mysql_config
$ vim site.cfg
修改mysql_config为mysql配置文件的路径 /usr/bin/mysql_config
还要修改
threadsafe = False
$ python setup.py build
$ sudo python setup.py install
$ python setup.py build
$ sudo python setup.py install
遇到错误:
- _mysql.c:2422: 错误:(在 ‘_mysql_ResultObject_memberlist[0].offset’ 的初始化附近)
- _mysql.c: In function ‘_mysql_ConnectionObject_getattr’:
- _mysql.c:2444: 错误:‘_mysql_ConnectionObject’ 没有名为 ‘open’ 的成员
- error: command ‘gcc’ failed with exit status 1
解决方法:
继续google 这回中文网站没有了 ,只能硬着头皮看外国人论坛
Result:
Hello, The package names required are python-devel and librsync-devel and build-essential
于是:
sudo apt-get install build-essential python-dev libmysqld-dev libmysql++-dev
使用环境:ubuntu 12.04 32
遇到问题:
/usr/bin/ld: cannot find -lpython2.7
解决方法:
试下做个软链接
cd /usr/lib/;ln -s /usr/local/Python2.7/lib/libpython2.7.so
转载随意~:陶醉 » linux安装MySQLdb