本文讲述了python安装mysql-python的方法。分享给大家供大家参考,具体如下:
ubuntu 系统下进行的操作
首先安装了pip工具
1
|
sudo apt-get install python-pip |
然后使用
1
|
sudo pip install mysql-python |
安装第三方库.但是此时报错
1
2
3
4
5
6
7
8
9
|
sh: mysql_config: not found Traceback (most recent call last): File "setup.py" , line 15, in <module> metadata, options = get_config() File "/home/zhxia/apps/source/MySQL-python-1.2.3/setup_posix.py" , line 43, in get_config libs = mysql_config( "libs_r" ) File "/home/zhxia/apps/source/MySQL-python-1.2.3/setup_posix.py" , line 24, in mysql_config raise EnvironmentError( "%s not found" % (mysql_config.path,)) EnvironmentError: mysql_config not found |
原因是没有安装:libmysqlclient-dev
1
|
sudo apt-get install libmysqlclient-dev |
继续安装 发现 还是报错
mysql.c:29:20: fatal error: Python.h: 没有那个文件或目录,找不到Python头文件,难道wheezy默认没有安装python开发包?
1
|
sudo dpkg -l | grep python-dev |
果然没有,还真的需要安装:
1
|
sudo apt-get install python-dev |
MySQL-python就可以编译通过了。