当前位置:计算机技术 - centos 错误删除(卸载)python2.7,安装python3.6


centos 错误删除(卸载)python2.7,安装python3.6
原创:netnorth 阅读次数:3644 日期:2019-08-02

不应该删除python2.7,yum需要用,重新安装3.6就行

--------------------------------

重新安装python2.7和yum

1、卸载现有的python

强制删除已安装程序及其关联

rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps 强制删除所有残余文件

whereis python |xargs rm -frv

2、卸载现有的yum

rpm -qa|grep yum|xargs rpm -ev --allmatches --nodeps 强制删除所有残余文件

whereis yum |xargs rm -frv


3、下载rpm

1)#mkdir python

#cd python 

wget http://mirror.retentionrange.co.bw/centOS/7.6.1810/os/x86_64/Packages/python-2.7.5-76.el7.x86_64.rpm

wget http://mirror.retentionrange.co.bw/centOS/7.6.1810/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm

wget http://mirror.retentionrange.co.bw/centOS/7.6.1810/os/x86_64/Packages/python-devel-2.7.5-76.el7.x86_64.rpm

wget http://mirror.retentionrange.co.bw/centOS/7.6.1810/os/x86_64/Packages/python-pycurl-7.19.0-19.el7.x86_64.rpm

wget http://mirror.retentionrange.co.bw/centOS/7.6.1810/os/x86_64/Packages/python-libs-2.7.5-76.el7.x86_64.rpm

wget http://mirror.retentionrange.co.bw/centOS/7.6.1810/os/x86_64/Packages/python-urlgrabber-3.10-9.el7.noarch.rpm

wget http://mirror.retentionrange.co.bw/centOS/7.6.1810/os/x86_64/Packages/rpm-python-4.11.3-35.el7.x86_64.rpm


#rpm -ivh python-*   rpm-python-*


出现安装包的依赖问题,此时如下解决即可:

#rpm -ivh python-*   rpm-python-* --nodeps --force

2)#mkdir yum

#cd yum

wget http://mirror.retentionrange.co.bw/centOS/7.6.1810/os/x86_64/Packages/yum-3.4.3-161.el7.centos.noarch.rpm

wget http://mirror.retentionrange.co.bw/centOS/7.6.1810/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm

wget http://mirror.retentionrange.co.bw/centOS/7.6.1810/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm

#rpm -ivh yum-*

----------------------------------------------------

以上重新安装python2.7和yum结束。

==========================my分割线==================

centos 7.4(7.0-7.5版本下载如下)

wget http://mirror.retentionrange.co.bw/centOS/7/os/x86_64/Packages/libxml2-python-2.9.1-6.el7_2.3.x86_64.rpm

wget http://mirror.retentionrange.co.bw/centOS/7/os/x86_64/Packages/rpm-4.11.3-35.el7.x86_64.rpm

wget http://mirror.retentionrange.co.bw/centOS/7/os/x86_64/Packages/rpm-build-4.11.3-35.el7.x86_64.rpm

wget http://mirror.retentionrange.co.bw/centOS/7/os/x86_64/Packages/rpm-build-libs-4.11.3-35.el7.x86_64.rpm

wget http://mirror.retentionrange.co.bw/centOS/7/os/x86_64/Packages/rpm-libs-4.11.3-35.el7.x86_64.rpm

wget http://mirror.retentionrange.co.bw/centOS/7/os/x86_64/Packages/rpm-sign-4.11.3-35.el7.x86_64.rpm

wget http://mirror.retentionrange.co.bw/centOS/7/os/x86_64/Packages/rpm-python-4.11.3-35.el7.x86_64.rpm

wget http://mirror.retentionrange.co.bw/centOS/7/os/x86_64/Packages/python-2.7.5-76.el7.x86_64.rpm

wget http://mirror.retentionrange.co.bw/centOS/7/os/x86_64/Packages/python-devel-2.7.5-76.el7.x86_64.rpm

wget http://mirror.retentionrange.co.bw/centOS/7/os/x86_64/Packages/python-libs-2.7.5-76.el7.x86_64.rpm

wget http://mirror.retentionrange.co.bw/centOS/7/os/x86_64/Packages/python-pycurl-7.19.0-19.el7.x86_64.rpm

wget http://mirror.retentionrange.co.bw/centOS/7/os/x86_64/Packages/python-setuptools-0.9.8-7.el7.noarch.rpm

wget http://mirror.retentionrange.co.bw/centOS/7/os/x86_64/Packages/python-urlgrabber-3.10-9.el7.noarch.rpm

wget http://mirror.retentionrange.co.bw/centOS/7/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm

wget http://mirror.retentionrange.co.bw/centOS/7/os/x86_64/Packages/python-backports-1.0-8.el7.x86_64.rpm

wget http://mirror.retentionrange.co.bw/centOS/7/os/x86_64/Packages/python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch.rpm

wget http://mirror.retentionrange.co.bw/centOS/7/os/x86_64/Packages/python-chardet-2.2.1-1.el7_1.noarch.rpm

wget http://mirror.retentionrange.co.bw/centOS/7/os/x86_64/Packages/python-ipaddress-1.0.16-2.el7.noarch.rpm

wget http://mirror.retentionrange.co.bw/centOS/7/os/x86_64/Packages/python-kitchen-1.1.1-5.el7.noarch.rpm

wget http://mirror.retentionrange.co.bw/centOS/7/os/x86_64/Packages/python-virtualenv-15.1.0-2.el7.noarch.rpm

wget http://mirror.retentionrange.co.bw/centOS/7/os/x86_64/Packages/yum-3.4.3-161.el7.centos.noarch.rpm

wget http://mirror.retentionrange.co.bw/centOS/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm

wget http://mirror.retentionrange.co.bw/centOS/7/os/x86_64/Packages/yum-utils-1.1.31-50.el7.noarch.rpm

wget http://mirror.retentionrange.co.bw/centOS/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm

wget http://mirror.retentionrange.co.bw/centOS/7/os/x86_64/Packages/yum-plugin-protectbase-1.1.31-50.el7.noarch.rpm

wget http://mirror.retentionrange.co.bw/centOS/7/os/x86_64/Packages/yum-plugin-aliases-1.1.31-50.el7.noarch.rpm


#rpm -Uvh --force --nodeps --replacepkgs *.rpm

-----------------------------python2.7升级到python3.6(3.7 3.8)---------------------------

#wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz

tar -xzvf Python-3.7.4.tgz

解压到当前目录

cd Python-3.7.4

进入解压后的目录

./configure --prefix=/usr/local/python

安装到/usr/local/python目录,不用事先创建python目录

make

编译

make install

安装

cd /usr/bin

进入/usr/bin目录

mv python python.bak

mv pip pip.bak

重命名python2的快捷方式

ln -s /usr/local/python/bin/python3.6 /usr/bin/python

ln -s /usr/local/python/bin/pip3.6 /usr/bin/pip

创建python3与pip3软连接

ll yum*

查看/usr/bin目录下有哪些yum文件

把这些文件的第一行#!/usr/bin/python改为#!/usr/bin/python2(2.7)

因为yum是依赖python的,所以我们修改了默认的python,就要修改yum,让其运行指向python2

修改urlgrabber配置文件

vim /usr/libexec/urlgrabber-ext-down

把第一行#!/usr/bin/python 改为 #!/usr/bin/python2(2.7)


公司概况
华旅网络是一家致力于软件开发、网络设计的互联网公司...
公司业务:软件开发,网站设计,企业CI设计,旅游、美食、交友互动平台......
友情链接

华旅网络官网(Official Website): h.91city.com h.c.91city.com 282509570.c.91city.com
©2017 华旅网络 版权所有 苏ICP备12078118号