redhat 6.4重新安装python和yum

 

 使用pip出错

错误:pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available

原因:

系统版本redhat6.4,其中openssl的版本为OpenSSL 1.0.1e-fips 11 Feb 2013,而python3.7需要的openssl的版本为1.0.2或者1.1.x,需要对openssl进行升级,并重新编译python3.7.0。yum 安装的openssl 版本都比较低。

操作:

这里因为pthon3.7不支持redhat6.4 的yum命令,所以不使用python3.7,我们回退python的版本为redhat6.4原装版本,也不用升级openssl,避免更多问题。

使用yum出错

错误:No module named yum

原因:

使用了rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps卸载python,系统原有的python被完全清除,导致依赖原有pythonyum命令无法使用。到python官网重新下载python2.6.6编译安装后依旧失效,可能是没有自带yum模块。保险起见需要找到redhat6.4的原始安装包,对应为centos6Package

操作

redhat6.4重装pythonyum

一、卸载python

  1. whereis python  # 查看当前系统安装的python包
  2. rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps   ##强制删除系统安装程序python包及其相关
  3. whereis python |xargs rm -frv   ##删除所有残余文件 ##xargs,允许你对输出执行其他某些命令
  4. whereis python ##验证删除,返回无结果

二、卸载yum

  1. rpm -qa|grep yum|xargs rpm -ev --allmatches --nodeps
  2. whereis yum |xargs rm -frv

三、到http://mirrors.ustc.edu.cn/centos/6下重新下载以下安装包

wget http://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages/python-2.6.6-66.el6_8.x86_64.rpm

wget http://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages/python-devel-2.6.6-66.el6_8.x86_64.rpm

wget http://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages/python-libs-2.6.6-66.el6_8.x86_64.rpm

wget http://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages/python-pycurl-7.19.0-9.el6.x86_64.rpm

wget http://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages/python-setuptools-0.6.10-4.el6_9.noarch.rpm

wget http://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages/python-urlgrabber-3.9.1-11.el6.noarch.rpm

wget http://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm

wget http://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages/rpm-python-4.8.0-59.el6.x86_64.rpm

wget http://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages/yum-3.2.29-81.el6.centos.noarch.rpm

wget http://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm

wget http://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages/yum-utils-1.1.30-41.el6.noarch.rpm

wget http://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm

wget http://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages/yum-plugin-protectbase-1.1.30-41.el6.noarch.rpm

wget http://mirrors.ustc.edu.cn/centos/6/os/x86_64/Packages/yum-plugin-aliases-1.1.30-41.el6.noarch.rpm

四、在安装包目录执行以下命令

rpm -Uvh --replacepkgs python*.rpm

rpm -Uvh --replacepkgs rpm-python*.rpm yum*.rpm

五、测试

python -V

yum -y install vim

原文地址:https://www.cnblogs.com/schoolbag/p/13786590.html