安装MysqlDB
MysqlDB下载地址
https://pypi.python.org/packages/source/M/MySQL-python/MySQL-python-1.2.3.tar.gz#md5=215eddb6d853f6f4be5b4afc4154292f
1、下载并解压mysqldb
- # wget https://pypi.python.org/packages/source/M/MySQL-python/MySQL-python-1.2.3.tar.gz#md5=215eddb6d853f6f4be5b4afc4154292f
- #tar -zxvf MySQL-python-1.2.3.tar.gz
- #cd MySQL-python-1.2.3/
- #python setup.py build
- #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
- wget https://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz#md5=7df2a529a074f613b509fb44feefe74e
- #chmod +x setuptools-0.6c11-py2.7.egg
- #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一下
解决:
- #apt-get install libmysqld-dev
- #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包
- #apt-get install Python-dev