在python中安装mysqldb模块

正常的安装过程

  wget "http://downloads.sourceforge.net/project/mysql-python/mysql-python\
/1.2.3/MySQL-python-1.2.3.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects\
%2Fmysql-python%2Ffiles%2F&ts=1304062611&use_mirror=nchc"
  tar xzvf MySQL-python-1.2.3.tar.gz
  cd MySQL-python-1.2.3
  python setup.py build
  python setup.py install

常见错误及其修复

  • ImportError: No module named setuptools

    wget http://pypi.python.org/packages/2.4/s/setuptools/setuptools-0.6c11-py2.4.egg\
    #md5=bd639f9b0eac4c42497034dec2ec0c2b
    sh setuptools-0.6c11-py2.4.egg
    
  • mysql_config: command not found

    sed --in-place -e "s/#mysql_config = \/usr\/local\/bin\/mysql_config/\
    mysql_config = \/usr\/local\/mysql\/bin\/mysql_config/g" site.cfg
    
  • ImportError: … _mysql.so: undefined symbol: compress

    sed --in-place -e "s/libs = mysql_config(\"libs_r\")/libs = mysql_config(\"libs_r\")\n\
    libs.append('-lz')\n        print libs/g" setup_posix.py