前言
工作中有需要用到gitlab ci/cd,需要在服务器上安装 nodejs,结果因为python版本过低问题安装不了,然后在搞python升级到3版本,结果越搞越头大,环境全都搞乱了,一气之下把python全删了,结果发现yum有依赖到python,我敲。。死活搞不明白,直接全删了吧,然后重新整一遍,以此记录!
卸载python和yum
卸载python
rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps
whereis python |xargs rm -frv
whereis python
卸载yum
rpm -qa|grep yum|xargs rpm -ev --allmatches --nodeps
whereis yum |xargs rm -frv
whereis yum
下载依赖包
先看一下自己的系统是什么版本的,不要下载错了。
依赖包地址,注意选择好自己对应的系统版本
http://vault.centos.org/
我的是7.8.2003的,我需要的包在https://vault.centos.org/7.8.2003/os/x86_64/Packages/下面
两种下载方式,一种在线wget下载,另一种就是你先下载到本地,然后通过ftp工具传送到服务器即可。
我这里直接采用wget下载,提供一下下载的包7.8.2003的
把python和yum分开下载到不同的目录下
mkdir /usr/local/src/python
mkdir /usr/local/src/yum
下载python
先进入python目录
cd /usr/local/src/python
下载
wget http://vault.centos.org/7.8.2003/os/x86_64/Packages/python-2.7.5-88.el7.x86_64.rpm
wget http://vault.centos.org/7.8.2003/os/x86_64/Packages/python-devel-2.7.5-88.el7.x86_64.rpm
wget http://vault.centos.org/7.8.2003/os/x86_64/Packages/python-libs-2.7.5-88.el7.x86_64.rpm
wget http://vault.centos.org/7.8.2003/os/x86_64/Packages/python-pycurl-7.19.0-19.el7.x86_64.rpm
wget http://vault.centos.org/7.8.2003/os/x86_64/Packages/python-setuptools-0.9.8-7.el7.noarch.rpm
wget http://vault.centos.org/7.8.2003/os/x86_64/Packages/python-urlgrabber-3.10-10.el7.noarch.rpm
wget http://vault.centos.org/7.8.2003/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
wget http://vault.centos.org/7.8.2003/os/x86_64/Packages/rpm-python-4.11.3-43.el7.x86_64.rpm
下载yum
先进入yum目录
cd /usr/local/src/yum
下载
wget http://vault.centos.org/7.8.2003/os/x86_64/Packages/yum-3.4.3-167.el7.centos.noarch.rpm
wget http://vault.centos.org/7.8.2003/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget http://vault.centos.org/7.8.2003/os/x86_64/Packages/yum-utils-1.1.31-53.el7.noarch.rpm
wget http://vault.centos.org/7.8.2003/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-53.el7.noarch.rpm
wget http://vault.centos.org/7.8.2003/os/x86_64/Packages/yum-plugin-protectbase-1.1.31-53.el7.noarch.rpm
wget http://vault.centos.org/7.8.2003/os/x86_64/Packages/yum-plugin-aliases-1.1.31-53.el7.noarch.rpm
安装
安装python
进入目录
cd /usr/local/src/python
强制性安装(很可能出现安装包依赖问题,所以直接强制性安装即可)
rpm -ivh python-* rpm-python-* --nodeps --force
安装完成
python -V
安装yum
进入目录
cd /usr/local/src/yum
强制性安装
rpm -ivh yum-* --nodeps --force
安装后,即可正常使用!
参考
参考自
https://blog.csdn.net/m0_38072683/article/details/104470093
https://www.cnblogs.com/wangjunjiehome/p/9239005.html
|