MysqlDB安装及错误解决

 安装MysqlDB

MysqlDB下载地址
https://pypi.python.org/packages/source/M/MySQL-python/MySQL-python-1.2.3.tar.gz#md5=215eddb6d853f6f4be5b4afc4154292f
 
1、下载并解压mysqldb
 
  
  
  
  
  1. # wget https://pypi.python.org/packages/source/M/MySQL-python/MySQL-python-1.2.3.tar.gz#md5=215eddb6d853f6f4be5b4afc4154292f 
  2. #tar -zxvf MySQL-python-1.2.3.tar.gz 
  3. #cd MySQL-python-1.2.3/ 
  4. #python setup.py build 
  5. #python setup.py install 
错误1:No module named setuptools
 
Traceback (most recent call last):
  File "setup.py", line 5, in <module>
    from setuptools import setup, Extension
ImportError: No module named setuptools
 
解决办法:下载安装setuptools
setuptools下载地址
https://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz#md5=7df2a529a074f613b509fb44feefe74e
 
  
  
  
  
  1. wget https://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz#md5=7df2a529a074f613b509fb44feefe74e 
  2. #chmod +x setuptools-0.6c11-py2.7.egg 
  3. #sh setuptools-0.6c11-py2.7.egg 

错误2:mysql_config: not found
 
sh: 1: mysql_config: not found
Traceback (most recent call last):
  File "setup.py", line 15, in <module>
    metadata, options = get_config()
  File "/home/zhenggs/MySQL-python-1.2.3/setup_posix.py", line 43, in get_config
    libs = mysql_config("libs_r")
  File "/home/zhenggs/MySQL-python-1.2.3/setup_posix.py", line 24, in mysql_config
    raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
 
原因:apt-get安装的mysql没有这个文件,可以find一下
解决:
 
  
  
  
  
  1. #apt-get install libmysqld-dev 
  2. #find / -name mysql_config 
然后修改MySQL-python-1.2.3目录下的site.cfg文件
加入mysql_config=/usr/bin/mysql_config  等于号后面的路径是find的结果,也就是mysql_config的路径
继续python setup.py build
 
错误3:
fatal error: Python.h: No such file or directory
 
安装Python-dev包
 
  
  
  
  
  1. #apt-get install Python-dev 
 
 
 

你可能感兴趣的:(MysqlDB安装)