Linux下安装yum(在删除原版本的python前提下导致了yum不好使)

1. 删除python及yum相关文件

1、删除现有Python

rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps ##强制删除已安装程序及其关联
whereis python |xargs rm -frv -rf ##删除所有残余文件 ##xargs,允许你对输出执行其他某些命令
whereis python ##验证删除,返回无结果

2、删除现有的yum

rpm -qa|grep yum|xargs rpm -ev --allmatches --nodeps
whereis yum |xargs rm -frv -rf

2. 从 http://mirrors.163.com/centos/7/os/x86_64/Packages/ 下载并安装python和yum程序包及其依赖包

python-devel-2.7.5-68.el7.x86_64.rpm
python-iniparse-0.4-9.el7.noarch.rpm
python-libs-2.7.5-68.el7.x86_64.rpm
python-pycurl-7.19.0-19.el7.x86_64.rpm
python-setuptools-0.9.8-7.el7.noarch.rpm
python-urlgrabber-3.10-8.el7.noarch.rpm
rpm-python-4.11.3-32.el7.x86_64.rpm
yum-3.4.3-158.el7.centos.noarch.rpm
yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
yum-plugin-aliases-1.1.31-45.el7.noarch.rpm
yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm
yum-plugin-protectbase-1.1.31-45.el7.noarch.rpm
ls -al

total 9092
drwxr-xr-x   2 root root    4096 Nov 19 18:04 .
dr-xr-x---. 12 root root    4096 Mar  3 19:28 ..
-rw-r--r--   1 root root  252528 Jun 24  2016 libxml2-python-2.9.1-6.el7_2.3.x86_64.rpm
-rw-r--r--   1 root root  186380 Apr 25  2018 lvm2-python-libs-2.02.177-4.el7.x86_64.rpm
-rw-r--r--   1 root root   95100 Apr 25  2018 python-2.7.5-68.el7.x86_64.rpm
-rw-r--r--   1 root root    5932 Mar 14  2015 python-backports-1.0-8.el7.x86_64.rpm
-rw-r--r--   1 root root   12896 Apr 25  2018 python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch.rpm
-rw-r--r--   1 root root  232224 Jul 23  2015 python-chardet-2.2.1-1.el7_1.noarch.rpm
-rw-r--r--   1 root root   39800 Jul  4  2014 python-iniparse-0.4-9.el7.noarch.rpm
-rw-r--r--   1 root root   35176 Nov 21  2016 python-ipaddress-1.0.16-2.el7.noarch.rpm
-rw-r--r--   1 root root  273012 Jul  4  2014 python-kitchen-1.1.1-5.el7.noarch.rpm
-rw-r--r--   1 root root 5914136 Apr 25  2018 python-libs-2.7.5-68.el7.x86_64.rpm
-rw-r--r--   1 root root   82396 Nov 21  2016 python-pycurl-7.19.0-19.el7.x86_64.rpm
-rw-r--r--   1 root root  406404 Aug 11  2017 python-setuptools-0.9.8-7.el7.noarch
-rw-r--r--   1 root root  110540 Nov 21  2016 python-urlgrabber-3.10-8.el7.noarch.rpm
-rw-r--r--   1 root root   83916 Apr 25  2018 rpm-python-4.11.3-32.el7.x86_64.rpm
-rw-r--r--   1 root root 1292216 Apr 25  2018 yum-3.4.3-158.el7.centos.noarch.rpm
-rw-r--r--   1 root root   28348 Jul  4  2014 yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
-rw-r--r--   1 root root   30664 Apr 25  2018 yum-plugin-aliases-1.1.31-45.el7.noarch
-rw-r--r--   1 root root   33660 Apr 25  2018 yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm
-rw-r--r--   1 root root   26468 Apr 25  2018 yum-plugin-protectbase-1.1.31-45.el7.noarch.rpm
-rw-r--r--   1 root root  122324 Apr 25  2018 yum-utils-1.1.31-45.el7.noarch

3. 修改文件名

mv python-setuptools-0.9.8-7.el7.noarch.rpm python-setuptools-0.9.8-7.el7.noarch
mv yum-utils-1.1.31-45.el7.noarch.rpm yum-utils-1.1.31-45.el7.noarch
mv yum-plugin-aliases-1.1.31-45.el7.noarch.rpm yum-plugin-aliases-1.1.31-45.el7.noarch

4. 进行安装

rpm -Uvh --replacepkgs lvm2-python-libs*.rpm
rpm -Uvh --replacepkgs libxml2-python*.rpm
rpm -Uvh --replacepkgs python*.rpm
rpm -Uvh --replacepkgs rpm-python*.rpm yum*.rpm

5. 测试python2.7是否可用

yum

// An highlighted block
Loaded plugins: fastestmirror, protectbase
You need to give some command
Usage: yum [options] COMMAND

List of Commands:

check          Check for problems in the rpmdb
check-update   Check for available package updates
clean          Remove cached data
deplist        List a package's dependencies
distribution-synchronization Synchronize installed packages to the latest available versions
downgrade      downgrade a package
erase          Remove a package or packages from your system
fs             Acts on the filesystem data of the host, mainly for removing docs/lanuages for minimal hosts.
fssnapshot     Creates filesystem snapshots, or lists/deletes current snapshots.
groups         Display, or use, the groups information
help           Display a helpful usage message
history        Display, or use, the transaction history
info           Display details about a package or group of packages
install        Install a package or packages on your system
list           List a package or groups of packages
load-transaction load a saved transaction from filename
makecache      Generate the metadata cache
provides       Find what package provides the given value
reinstall      reinstall a package
repo-pkgs      Treat a repo. as a group of packages, so we can install/remove all of them
repolist       Display the configured software repositories
search         Search package details for the given string
shell          Run an interactive yum shell
swap           Simple way to swap packages, instead of using shell
update         Update a package or packages on your system
update-minimal Works like upgrade, but goes to the 'newest' package match which fixes a problem that affects your system
updateinfo     Acts on repository update information
upgrade        Update packages taking obsoletes into account
version        Display a version for the machine and/or available repos.


Options:
  -h, --help            show this help message and exit
  -t, --tolerant        be tolerant of errors
  -C, --cacheonly       run entirely from system cache, don't update cache
  -c [config file], --config=[config file]
                        config file location
  -R [minutes], --randomwait=[minutes]
                        maximum command wait time
  -d [debug level], --debuglevel=[debug level]
                        debugging output level
  --showduplicates      show duplicates, in repos, in list/search commands
  -e [error level], --errorlevel=[error level]
                        error output level
  --rpmverbosity=[debug level name]
                        debugging output level for rpm
  -q, --quiet           quiet operation
  -v, --verbose         verbose operation
  -y, --assumeyes       answer yes for all questions
  --assumeno            answer no for all questions
  --version             show Yum version and exit
  --installroot=[path]  set install root
  --enablerepo=[repo]   enable one or more repositories (wildcards allowed)
  --disablerepo=[repo]  disable one or more repositories (wildcards allowed)
  -x [package], --exclude=[package]
                        exclude package(s) by name or glob
  --disableexcludes=[repo]
                        disable exclude from main, for a repo or for
                        everything
  --disableincludes=[repo]
                        disable includepkgs for a repo or for everything
  --obsoletes           enable obsoletes processing during updates
  --noplugins           disable Yum plugins
  --nogpgcheck          disable gpg signature checking
  --disableplugin=[plugin]
                        disable plugins by name
  --enableplugin=[plugin]
                        enable plugins by name
  --skip-broken         skip packages with depsolving problems
  --color=COLOR         control whether color is used
  --releasever=RELEASEVER
                        set value of $releasever in yum config and repo files
  --downloadonly        don't update, just download
  --downloaddir=DLDIR   specifies an alternate directory to store packages
  --setopt=SETOPTS      set arbitrary config and repo options
  --bugfix              Include bugfix relevant packages, in updates
  --security            Include security relevant packages, in updates
  --advisory=ADVS, --advisories=ADVS
                        Include packages needed to fix the given advisory, in
                        updates
  --bzs=BZS             Include packages needed to fix the given BZ, in
                        updates
  --cves=CVES           Include packages needed to fix the given CVE, in
                        updates
  --sec-severity=SEVS, --secseverity=SEVS
                        Include security relevant packages matching the
                        severity, in updates

  Plugin Options:
  [root@iz2ze06kmfgcyh69s9q3luz ~]# 

yum命令正常 至此完全安装python2.7及yum完成!!

6. 下载链接

https://download.csdn.net/download/ykenan/11464944

参考网址:
[1]: https://blog.csdn.net/one312/article/details/81051023
[2]: https://blog.csdn.net/chengpeng1996/article/details/81216230

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值