ImportError: No module named MySQLdb解决办法
今天突发奇想在服务器上使用web页面查看系统状态,但又不想去搭建太复杂的监控系统,就在网上找了个相对容易的监控方式,但做到python那步的时候居然报ImportError: No module named MySQLdb,但博主说他是ubuntu的系统可以直接使用apt-get install python-mysqldb,而我是centos系统,只能自己去下源码包来安装.
系统:centos 5.9
需要的软件包:setuptools-0.6c11.tar.gz
MySQL-python-1.2.3.tar.gz
1.安装setuptools-0.6c11
wget --no-check-certificate http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz
tar zxf setuptools-0.6c11.tar.gz && cd setuptools-0.6c11
python setup.py build
python setup.py install
2.安装MySQL-python-1.2.3
wget http://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.3/MySQL-python-1.2.3.tar.gz/download
tar zxf MySQL-python-1.2.3.tar.gz && cd MySQL-python-1.2.3
python setup.py build
python setup.py install
如果在执行python setup.py build时,报EnvironmentError: mysql_config not found的话,先查找mysql_config的位置,使用find / -name mysql_config,我的是在/usr/local/mysql/bin/mysql_config,然后修改MySQL-python-1.2.3目录下的site.cfg文件,去掉mysql_config=XXX这行的注释,并改成mysql_config=/usr/local/mysql/bin/mysql_config,以自己机器的为准.
再执行下面命令就可以了
python setup.py build
python setup.py install
好了,解决了MySQLdb的问题,我要继续去研究web监控系统的东西了.
系统:centos 5.9
需要的软件包:setuptools-0.6c11.tar.gz
MySQL-python-1.2.3.tar.gz
1.安装setuptools-0.6c11
wget --no-check-certificate http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz
tar zxf setuptools-0.6c11.tar.gz && cd setuptools-0.6c11
python setup.py build
python setup.py install
2.安装MySQL-python-1.2.3
wget http://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.3/MySQL-python-1.2.3.tar.gz/download
tar zxf MySQL-python-1.2.3.tar.gz && cd MySQL-python-1.2.3
python setup.py build
python setup.py install
如果在执行python setup.py build时,报EnvironmentError: mysql_config not found的话,先查找mysql_config的位置,使用find / -name mysql_config,我的是在/usr/local/mysql/bin/mysql_config,然后修改MySQL-python-1.2.3目录下的site.cfg文件,去掉mysql_config=XXX这行的注释,并改成mysql_config=/usr/local/mysql/bin/mysql_config,以自己机器的为准.
再执行下面命令就可以了
python setup.py build
python setup.py install
好了,解决了MySQLdb的问题,我要继续去研究web监控系统的东西了.
As a Fedora/EPEL packager, I just want to tell you that this package is named "python26-mysqldb" in EPEL5, and main package "MySQL-python" is named "MySQL-python" in @Base.
I'm sorry I don't install 中文 input method on my system.