centos5.6 安裝 python 2.7

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

1. install python 2.7python

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

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

./configure vim

makepython2.7

make installide

rm /usr/bin/pythonui

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

*******************.net

發現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'

相關文章
相關標籤/搜索