1.查看当前python版本
# python -V
Python 2.6.6 (r266:84292,Jul 23 2015,15:22:56)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2
Type "help","copyright","credits" or "license" for more information.
2.下载python2.7.5
# wget http://python.org/ftp/python/2.7.5/Python-2.7.5.tar.bz2
3.解压
#tar -jxvf Python-2.7.5.tar.bz2
4.配置SSL
# sudo yum install openssl-devel // 如果没有https,需要安装
#cd Python-2.7.5/Modules
# vi Setup.dist
找到:
# Socket module helper for SSL support; you must comment out the other
# socket line above,and possibly edit the SSL variable:
#SSL=/usr/local/ssl
#_ssl _ssl.c \
# -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
# -L$(SSL)/lib -lssl -lcrypto
改为:
# Socket module helper for SSL support; you must comment out the other
# socket line above,and possibly edit the SSL variable:
SSL=/usr/local/ssl
_ssl _ssl.c \
-DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
-L$(SSL)/lib -lssl -lcrypto
5.安装python2.7.5
#cd ..
#./configure
#make all
#make install
#make clean
#make distclean
6.建立软连接,使系统默认的 python指向 python2.7
#mv /usr/bin/python /usr/bin/python2.6.6
#ln -s /usr/local/bin/python2.7 /usr/bin/python
7.解决系统 Python 软链接指向 Python2.7 版本后,因为yum是不兼容 Python 2.7的,所以yum不能正常工作,我们需要指定 yum 的Python版本
#vi /usr/bin/yum
将文件头部的
#!/usr/bin/python
改成
#!/usr/bin/python2.6.6
8.安装easy_install
#wget -q http://peak.telecommunity.com/dist/ez_setup.py
#python ez_setup.py
9.安装python包管理安装工具pip
#wget --no-check-certificate https://github.com/pypa/pip/archive/1.5.5.tar.gz
#tar zvxf 1.5.5.tar.gz #解压文件
#cd pip-1.5.5/
#python setup.py install
10. 安装APSchedule
#easy_installapscheduler
报错:
ImportError: <module 'setuptools.dist' from '/usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/dist.pyc'> has no 'check_specifier' attribute
$ sudo pip install setuptools --upgrade
然后再次执行 #easy_installapscheduler 成功
原文链接:https://www.f2er.com/centos/377093.html