转自:http://blog.csdn.net/dqatsh/article/details/6592989

1. install python 2.7

refer: http://www.cnblogs.com/minglog/archive/2011/04/20/2022479.html

wget http://www.python.org/ftp/python/2.7.2/Python-2.7.2.tar.bz2

./configure

make

make install

rm /usr/bin/python

ln -s /usr/local/bin/python2.7 /usr/bin/python

*******************

发现yum不能用了,yum依赖python2.4, 处理如下:

vim /usr/bin/yum

将文件头部的

#!/usr/bin/python

改成

#!/usr/bin/python2.4

就可以继续使用yum了

*******************

2. install setuptools

wget http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg#md5=fe1f997bc722265116870bc7919059ea

sh setuptools-0.6c11-py2.7.egg

3. install python modules

.feedparser

#easy_install feedparser 编码处理有些问题

下载feedparser-5.0.1源码

feedparser.py 3524行

elif http_content_type.startswith('text/'):

        #true_encoding = http_encoding or 'us-ascii'

        true_encoding = http_encoding or xml_encoding or 'utf-8'

  python setup.py build

        python setup.py install

        .BeautifulSoup

easy_install BeautifulSoup

        .chardet

easy_install chardet

.PIL

yum install libjpeg-devel zlib-devel freetype-devel

#easy_install PIL #has problems, not support jpeg, etc

wget http://effbot.org/downloads/Imaging-1.1.7.tar.gz

python setup.py build_ext -i

python setup.py install

.MySQLdb

yum install mysql-devel

http://ncu.dl.sourceforge.net/project/mysql-python/mysql-python/1.2.3/MySQL-python-1.2.3.tar.gz

python setup.py build

python setup.py install

4. Tips

easy_install安装后如何删除

编辑 /usr/local/lib/python2.7/site-packages/easy-install.pth , 删除相应的行。删除相应的egg文件。

python -u

-u     : unbuffered binary stdout and stderr; also PYTHONUNBUFFERED=x
         see man page for details on internal buffering relating to '-u'