Home > Article > Backend Development > Python下的Mysql模块MySQLdb安装详解
默认情况下,MySQLdb包是没有安装的,不信? 看到类似下面的代码你就信了。
代码如下:
-bash-3.2# /usr/local/python2.7.3/bin/python get_cnblogs_news.py
Traceback (most recent call last):
File "get_cnblogs_news.py", line 9, in
import MySQLdb
ImportError: No module named MySQLdb
代码如下:
wget http://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.3/MySQL-python-1.2.3.tar.gz
代码如下:
tar zxvf MySQL-python-1.2.3.tar.gz
代码如下:
$ cd MySQL-python-1.2.3
$ python setup.py build
$ python setup.py install
代码如下:
EnvironmentError: mysql_config not found
代码如下:
mysql_config.path = “/usr/local/mysql/bin/mysql_config”
代码如下:
python setup.py build
python setup.py install