Ubuntu16.04安装MySQLdb
buntu 系统下进行的操作
首先安装了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 |
报错:import MySQLdb
ImportError: No module named MySQLdb
安装:apt-get install python-mysqldb
如果python3,上面安装时python替换为python3,pip替换为pip3即可