服务器不知道被谁弄坏了 提示ImportError: No module named time,导致yum都无法使用
弄了很久没弄好也不知道什么原因导致的
所以决定重装python
步骤如下
一、卸载python
1)强制删除已安装python、yum其关联
rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps
rpm -qa|grep yum|xargs rpm -ev --allmatches --nodeps
2)删除残余文件
whereis python|xargs rm -frv
二、安装python
2.1下载pythonRPM包
备注:包是下的src源码包自己编译的,开始用tar包安装yum报错,不知道是不是安装有问题
python 源码rpm包地址下载地址:
https://vault.centos.org
选择对应的centos版本
updates/Source/SPackages/ 升级包路径
我选择的是python-2.7.5-90.el7.src.rpm
2.2编译
建议选同系统,且环境正常的机器下编译,不然编译安装编译依赖很麻烦
yum install rpm-build
rpmbuild --rebuild python-2.7.5-90.el7.src.rpm
第一次编译会提示你需要安装相关依赖
自己用yum 安装,
安装依赖完成后
rpmbuild --rebuild python-2.7.5-90.el7.src.rpm
安装成功提示如图

2.3安装PYTHON
cd /root/rpmbuild/RPMS/.../
把相关的包COPY到需要重装的机器
按顺序安装:
1:python-libs
2:python-2.7.5
安装完成后python已经可以使用

三、安装yum
rpm -ivh yum-3.4.3-168.el7.centos.noarch.rpm
安装依赖python-urlgrabber(依赖python-pycurl),python-iniparse,rpm-python
yum-metadata-parser yum-plugin-fastestmirror rpm-build-libs-4.11.3-45.el7.x86_64.rpm
yum-metadata-parser
python-iniparse-0.4-9.el7.noarch.rp
python-pycurl-7.19.0-19.el7.x86_64.rpm
python-urlgrabber
rpm-build-libs-4.11.3-45.el7.x86_64.rpm
rpm-python
最后2个插件一起安装
rpm -ivh yum-3.4.3-168.el7.centos.noarch.rpm yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm

输入YUM已经可以使用
安装pip
yum -y install epel-release
yum -y install python-pip

输入PIP已可以使用
推荐本站淘宝优惠价购买喜欢的宝贝:
本文链接:https://hqyman.cn/post/5365.html 非本站原创文章欢迎转载,原创文章需保留本站地址!
打赏

微信支付宝扫一扫,打赏作者吧~
休息一下~~