Mysqldb和webpy的安装

1.首先安装mysql

sudo apt-get install mysql-server

2.然后安装libmysqld-dev和libmysqlclient-dev,否则在安装Mysqldb的时候会报找不到mysql_config文件

sudo apt-get install libmysqld-dev
sudo apt-get install libmysqlclient-dev

3.安装完上述之后,到http://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.3/MySQL-python-1.2.3.tar.gz/download下载最新的Mysqldb的tar包,解压

修改site.cfg中的mysql_config的配置地址,一般上述装完后的默认地址为/usr/bin/mysql_config
运行下列命令即可
sudo python setup.py build
sudo python setup.py install
如果报错: ImportError: No module named setuptools,则需要安装 setuptools
sudo apt-get install python-setuptools
如果报下列错误:
building '_mysql' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC
 -Dversion_info=(1,2,3,'final',0) -D__version__=1.2.3
-I/u01/mysql/include/mysql -I/usr/include/python2.6 -c _mysql.c
-o build/temp.linux-i686-2.6/_mysql.o -DUNIV_LINUX
In file included from _mysql.c:29:
pymemcompat.h:10: fatal error: Python.h: 没有那个文件或目录
compilation terminated.
error: command 'gcc' failed with exit status 1

则需要安装python-dev

sudo apt-get install python-dev

4.最后安装web.py

sudo apt-get install python-webpy

你可能感兴趣的:(python,mysqldb)