前提是装了mysql
1、下载 MySQL-python-1.2.3.tar.gz
2、下面就直接执行命令了
cd Downloads/
tar xfz MySQL-python-1.2.3.tar.gz
vim setup_posix.py 改为
#mysql_config.path = "mysql_config"
mysql_config.path = "/usr/local/bin/mysql_config" #确定自己电脑有该文件
接着执行
python setup.py clean
python setup.py build
sudo python setup.py install
安装完成后执行python进入python命令行执行import MySQLdb 不会报错就OK了
出现问题:
'gcc' failed with exit status 1 解决办法:
yum install gcc python-devel
No module named setuptools解决办法 :
wget https://bootstrap.pypa.io/ez_setup.py -O - | python