centos7 python3.5安装mysqlclient1.3.9
MySQL-python目前不支持python3.5,可以使用mysqlclient
下载地址:https://pypi.python.org/pypi/mysqlclient/1.3.9
解压后进入目录:
$ python setup.py build
$ python setup.py install
出现报错:mysql_config not found 的解决方法
sudo yum install mysql-devel
再次执行安装命令
写个脚本验证是否安装成功
#!/usr/local/bin/python3 # -*- coding: utf-8 -*- import MySQLdb conn = MySQLdb.connect("localhost","root","root","test") cursor = conn.cursor() cursor.execute("SELECT VERSION()") data = cursor.fetchone() print(data); conn.close();