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

推荐订阅源

D
Darknet – Hacking Tools, Hacker News & Cyber Security
V
Vulnerabilities – Threatpost
Cloudbric
Cloudbric
G
GRAHAM CLULEY
S
Securelist
Schneier on Security
Schneier on Security
Help Net Security
Help Net Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Project Zero
Project Zero
Spread Privacy
Spread Privacy
P
Privacy International News Feed
C
Cyber Attacks, Cyber Crime and Cyber Security
Cisco Talos Blog
Cisco Talos Blog
T
Tailwind CSS Blog
博客园_首页
有赞技术团队
有赞技术团队
Simon Willison's Weblog
Simon Willison's Weblog
Stack Overflow Blog
Stack Overflow Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Latest news
Latest news
T
Tor Project blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Attack and Defense Labs
Attack and Defense Labs
www.infosecurity-magazine.com
www.infosecurity-magazine.com
O
OpenAI News
J
Java Code Geeks
T
Tenable Blog
K
Kaspersky official blog
AWS News Blog
AWS News Blog
S
Security @ Cisco Blogs
The GitHub Blog
The GitHub Blog
T
Threatpost
月光博客
月光博客
H
Heimdal Security Blog
Security Latest
Security Latest
The Hacker News
The Hacker News
Y
Y Combinator Blog
A
Arctic Wolf
Apple Machine Learning Research
Apple Machine Learning Research
C
Cisco Blogs
美团技术团队
Microsoft Security Blog
Microsoft Security Blog
Hugging Face - Blog
Hugging Face - Blog
T
The Blog of Author Tim Ferriss
C
CERT Recently Published Vulnerability Notes
D
Docker
Google Online Security Blog
Google Online Security Blog
D
DataBreaches.Net
V
Visual Studio Blog
H
Help Net Security

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个机房按小时计费,支持支付宝,【点击查看】。