因一次意外,不小心卸掉了服务器自带的python,导致yam不可用,故写此博客记录一番安装踩坑经历。
1.创建目录python和yum用以存放rpm包
mkdir /usr/local/src/python mkdir /usr/local/src/yum
2.下载python的rpm包:
2.1 cd /usr/local/src/python
进入目录
下载路径:http://vault.centos.org/7.4.1708/os/x86_64/Packages/(注意centos版本一定要正确,我的版本是7.4.1708)
下载的包有:
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-2.7.5-58.el7.x86_64.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-pycurl-7.19.0-19.el7.x86_64.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-devel-2.7.5-58.el7.x86_64.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-libs-2.7.5-58.el7.x86_64.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/python-urlgrabber-3.10-8.el7.noarch.rpm
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/rpm-python-4.11.3-25.el7.x86_64.rpm
————————————————
https://vault.centos.org/7.9.2009/os/x86_64/Packages/坑爹官网是没得下了,只能找第三方源下载http://www.centos.org/download
下面是7.9的,其他版本自己找https://mirrors.bfsu.edu.cn/centos/7.9.2009/os/x86_64/Packages/
wget https://mirrors.bfsu.edu.cn/centos/7.9.2009/os/x86_64/Packages/python-2.7.5-89.el7.x86_64.rpm
wget https://mirrors.bfsu.edu.cn/centos/7.9.2009/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
wget https://mirrors.bfsu.edu.cn/centos/7.9.2009/os/x86_64/Packages/python-devel-2.7.5-89.el7.x86_64.rpm
wget https://mirrors.bfsu.edu.cn/centos/7.9.2009/os/x86_64/Packages/python-libs-2.7.5-89.el7.x86_64.rpm
wget https://mirrors.bfsu.edu.cn/centos/7.9.2009/os/x86_64/Packages/python-urlgrabber-3.10-10.el7.noarch.rpm
wget https://mirrors.bfsu.edu.cn/centos/7.9.2009/os/x86_64/Packages/rpm-python-4.11.3-45.el7.x86_64.rpm
2.2安装python:
rpm -ivh python-* rpm-python-*
出现安装包的依赖问题时,解决方案:
rpm -ivh python-* rpm-python-* --nodeps --force
注: --nodeps --force为不考虑依赖包,强制安装
2.3检测是否安装成功
`python -V`---检测安装的版本号
3.下载yum的rpm包
3.1进入目录 cd /usr/local/src/yum
3.2 下载yum的rpm包:(注意系统的版本)
wget http://vault.centos.org/7.4.1708/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-42.el7.noarch.rpmwget http://vault.centos.org/7.4.1708/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpmwget http://vault.centos.org/7.4.1708/os/x86_64/Packages/yum-3.4.3-154.el7.centos.noarch.rpm
3.3
rpm -ivh yum-*cd /etc/yum.repos.d
yum clean all
yum makecache
至此,python2.7.5及yum就安装好了。
亲测可用。
推荐本站淘宝优惠价购买喜欢的宝贝:
本文链接:https://hqyman.cn/post/5351.html 非本站原创文章欢迎转载,原创文章需保留本站地址!
打赏微信支付宝扫一扫,打赏作者吧~
休息一下~~