centos7yum安装python3,同时解决yum失效

大宝 4420 0

centos7如何用 yum安装python3,安装Python3后,yum失效了,怎么解决?

查看Python版本

# python -V
Python 2.7.5

yum软件库

# yum install epel-release

安装Python

# yum search python3*

我这里显示有Python34和Python36,继续

# yum install python34
……
Is this ok [y/d/N]: y
Downloading packages:
python34-libs-3.4.9-1.el7.x86_64.rpm                                                                                                                                  | 8.3 MB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : python34-libs-3.4.9-1.el7.x86_64                                                                                                                                         1/2 
  正在安装    : python34-3.4.9-1.el7.x86_64                                                                                                                                              2/2 
  验证中      : python34-3.4.9-1.el7.x86_64                                                                                                                                              1/2 
  验证中      : python34-libs-3.4.9-1.el7.x86_64                                                                                                                                         2/2 

已安装:
  python34.x86_64 0:3.4.9-1.el7                                                                                                                                                              

作为依赖被安装:
  python34-libs.x86_64 0:3.4.9-1.el7                                                                                                                                                         

完毕!

软连接

# cd /usr/bin
# rm python
# ln -s python3.4 python
# python -V
Python 3.4.9

完毕,我这里的因为Python直接安装在了目录/usr/bin下,如果你的不是这样注意ln的位置一定要正确。

ln -s 源位置   目标位置

继续解决Yum不能使用的问题,因为老版本的Python我们并没有删除,所以直接指向老版本就可以了。

# vi /usr/bin/yum

改完后如图

centos7yum安装python3,同时解决yum失效-第1张图片-莱芜网站制作中心

改过不行,自己ll看看目录下老版本的文件名

centos7yum安装python3,同时解决yum失效-第2张图片-莱芜网站制作中心

全文结束,参考文章列表:

https://stackoverflow.com/questions/8087184/installing-python-3-on-rhel


标签: Python

抱歉,评论功能暂时关闭!