在RHEL 6上安装MySQL-python时出错

时间:2014-10-07 05:47:09

标签: python gcc pip mysql-python yum

我已经尝试过yum install MYSQL-python,pip install MySQL-python和easy_install MySQL-python。

收到此错误:error: command 'gcc' failed with exit status 1

Cleaning up...
Command /usr/local/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/MySQL-python/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-rpOkcR-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_root/MySQL-python
Traceback (most recent call last):
  File "/usr/local/bin/pip", line 8, in <module>
    load_entry_point('pip==1.5.6', 'console_scripts', 'pip')()
  File "/usr/local/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg/pip/__init__.py", line 185, in main
    return command.main(cmd_args)
  File "/usr/local/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg/pip/basecommand.py", line 161, in main
    text = '\n'.join(complete_log)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 65: ordinal not in range(128)

yum install工作了,它说:Package MySQL-python-1.2.3-0.3.c1.1.el6.x86_64 already installed and latest version.

但是当我打开python并输入:import MySQLdb时,它会显示ImportError: No module named mysqldb

甚至尝试通过yum install gcc或yum install python-devel手动安装gcc ...都没有用。

2 个答案:

答案 0 :(得分:0)

将终端编码设置为UTF-8,在终端中运行以下命令:

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8

答案 1 :(得分:0)

找到答案:yum install mysql-devel.x86_64

似乎yum install mysql-devel并没有这样做。不得不更具体..

Install mysql-python return error in CentOs