惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
SegmentFault 最新的问题
Spread Privacy
Spread Privacy
Google DeepMind News
Google DeepMind News
WordPress大学
WordPress大学
Blog — PlanetScale
Blog — PlanetScale
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Apple Machine Learning Research
Apple Machine Learning Research
SecWiki News
SecWiki News
腾讯CDC
P
Privacy International News Feed
Webroot Blog
Webroot Blog
J
Java Code Geeks
爱范儿
爱范儿
A
About on SuperTechFans
S
Secure Thoughts
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
D
DataBreaches.Net
Cloudbric
Cloudbric
Security Archives - TechRepublic
Security Archives - TechRepublic
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
C
Cyber Attacks, Cyber Crime and Cyber Security
P
Proofpoint News Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Security Latest
Security Latest
Forbes - Security
Forbes - Security
小众软件
小众软件
www.infosecurity-magazine.com
www.infosecurity-magazine.com
C
Cybersecurity and Infrastructure Security Agency CISA
T
Threatpost
量子位
MongoDB | Blog
MongoDB | Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
月光博客
月光博客
W
WeLiveSecurity
P
Privacy & Cybersecurity Law Blog
Vercel News
Vercel News
Google Online Security Blog
Google Online Security Blog
云风的 BLOG
云风的 BLOG
GbyAI
GbyAI
S
Security @ Cisco Blogs
T
The Exploit Database - CXSecurity.com
Help Net Security
Help Net Security
V
Visual Studio Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
Application and Cybersecurity Blog
Application and Cybersecurity Blog
博客园 - 聂微东
P
Proofpoint News Feed
C
CERT Recently Published Vulnerability Notes
Attack and Defense Labs
Attack and Defense Labs

Rat's Blog - Python

Linux VPS使用Python/Caddy快速搭建文件分享平台 - Rat's Blog Python 3.6一键安装脚本 for CentOS/Debian - Rat's Blog Linux VPS出现 “-bash: python: command not found”错误的解决方法 Linux CentOS升级Python 3.6版本方法 - Rat's Blog
Linux CentOS 6升级Python 2.6至Python 2.7的方法
博主: Rat's · 2015-12-27 · via Rat's Blog - Python
  •  发布时间:
  •  11546 次浏览
  •   暂无评论
  •  1120 字数
  • 分类: 主机教程
  1.  首页
  2. 正文  
  3. 分享到:

说明:现在很多软件安装都需要Python2.7支持了,不想折腾的可以直接用Centos 7.x,自带Python2.7,很多人还在用Centos 6.x,自带Python2.6,版本太低,而又不想换系统,所以只能手动升级了。

方法

1、检查当前Python版本

python -V

检查之后,我们可以看到是Python 2.6.6版本

2、升级系统和安装开发工具包

yum -y update
yum groupinstall "Development tools" -y

3、补充安装需要的组件支持

yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel -y

4、安装Python2.7.6

cd /opt
wget --no-check-certificate https://www.python.org/ftp/python/2.7.6/Python-2.7.6.tar.xz
tar xf Python-2.7.6.tar.xz
cd Python-2.7.6
./configure --prefix=/usr/local
sudo make && sudo make altinstall

注意了,这里是用的altinstall

5、检查是否安装

/usr/local/bin/python2.7 --version

目前,我们只能通过这个命令检查,看到Python 2.7.6版本。

6、创建软链接

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

移除原来的老版本,然后创建2.7的软链接。这样我们直接用Python -V可以看到已经是Python 2.7.6

7、修复兼容问题
另外,由于yum的依赖是python2.6,需要修改yum文件

vi /usr/bin/yum

编辑文件,在顶部修改成

#!/usr/bin/python2.6.6

保存退出!


版权声明:本文为原创文章,版权归 Rat's Blog 所有,转载请注明出处!

本文链接:https://www.moerats.com/archives/138/

如教程需要更新,或者相关链接出现404,可以在文章下面评论留言。

Vultr新用户注册送100美元/16个机房按小时计费,支持支付宝,【点击查看】。