1.安装
# 解压安装包 tar -zxvf MySQL-python-1.2.4b4.tar.gz # 切换到解压后的文件夹并将distribute-0.6.28.tar.gz文件复制到此文件夹下 cd MySQL-python-1.2.4b4 # 编译 python setup.py build # 安装 python setup.py install
2.问题记录
2.1 urllib2.HTTPError: HTTP Error 403: SSL is required
Downloading http://pypi.python.org/packages/source/d/distribute/distribute-0.6.28.tar.gz Traceback (most recent call last): File "setup.py", line 7, in <module> use_setuptools() File "/home/MySQL-python-1.2.4b4/distribute_setup.py", line 145, in use_setuptools return _do_download(version, download_base, to_dir, download_delay) File "/home/MySQL-python-1.2.4b4/distribute_setup.py", line 124, in _do_download to_dir, download_delay) File "/home/MySQL-python-1.2.4b4/distribute_setup.py", line 194, in download_setuptools src = urlopen(url) File "/usr/lib64/python2.7/urllib2.py", line 154, in urlopen return opener.open(url, data, timeout) File "/usr/lib64/python2.7/urllib2.py", line 437, in open response = meth(req, response) File "/usr/lib64/python2.7/urllib2.py", line 550, in http_response 'http', request, response, code, msg, hdrs) File "/usr/lib64/python2.7/urllib2.py", line 475, in error return self._call_chain(*args) File "/usr/lib64/python2.7/urllib2.py", line 409, in _call_chain result = func(*args) File "/usr/lib64/python2.7/urllib2.py", line 558, in http_error_default raise HTTPError(req.get_full_url(), code, msg, hdrs, fp) urllib2.HTTPError: HTTP Error 403: SSL is required
下载 distribute-0.6.28.tar.gz,放到/MySQL-python-1.2.4b4/文件夹下。
2.2 mysql_config not found
Extracting in /tmp/tmpHSdWW8 Now working in /tmp/tmpHSdWW8/distribute-0.6.28 Building a Distribute egg in /home/MySQL-python-1.2.4b4 /home/MySQL-python-1.2.4b4/distribute-0.6.28-py2.7.egg sh: mysql_config: command not found Traceback (most recent call last): File "setup.py", line 18, in <module> metadata, options = get_config() File "/home/MySQL-python-1.2.4b4/setup_posix.py", line 43, in get_config libs = mysql_config("libs_r") File "/home/MySQL-python-1.2.4b4/setup_posix.py", line 25, in mysql_config raise EnvironmentError("%s not found" % (mysql_config.path,)) EnvironmentError: mysql_config not found
解决
yum install mysql-devel
2.3 error: command ‘gcc’ failed with exit status 1
running build running build_py creating build creating build/lib.linux-x86_64-2.7 copying _mysql_exceptions.py -> build/lib.linux-x86_64-2.7 creating build/lib.linux-x86_64-2.7/MySQLdb copying MySQLdb/__init__.py -> build/lib.linux-x86_64-2.7/MySQLdb copying MySQLdb/converters.py -> build/lib.linux-x86_64-2.7/MySQLdb copying MySQLdb/connections.py -> build/lib.linux-x86_64-2.7/MySQLdb copying MySQLdb/cursors.py -> build/lib.linux-x86_64-2.7/MySQLdb copying MySQLdb/release.py -> build/lib.linux-x86_64-2.7/MySQLdb copying MySQLdb/times.py -> build/lib.linux-x86_64-2.7/MySQLdb creating build/lib.linux-x86_64-2.7/MySQLdb/constants copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants copying MySQLdb/constants/REFRESH.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants running build_ext building '_mysql' extension creating build/temp.linux-x86_64-2.7 gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -Dversion_info=(1,2,4,'beta',4) -D__version__=1.2.4b4 -I/usr/include/mysql -I/usr/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o _mysql.c:29:20: fatal error: Python.h: No such file or directory #include "Python.h" ^ compilation terminated. error: command 'gcc' failed with exit status 1
解决
yum install python-devel