时间:2021-07-01 10:21:17 帮助过:2人阅读
安装mysql开发包
apt-get install python-dev libmysqlclient-dev
通过pip安装Mysql For Python
pip install MySQL-python
测试,在Python命令行里输入import MySQLdb,看报不报错
xxx@ubuntu:~$ python Python 2.7.12 (default, Jul 1 2016, 15:12:24) [GCC 5.4.0 20160609] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import MySQLdb
注:用apt-get 命令时需要root权限,如果执行命令时用得不是root账户,需要使用sudo命令,比如安装python-pip时,需要输入
sudo apt-get install python-pip
参考how-to-set-up-mysql-for-python-on-ubuntu/
在Ubuntu上安装Mysql For Python
标签: