Centos – How to install YUM with CentOS with conflicting python versions

centospackage-managementyum

I have been searching all over the internet for the instructions to install yum on CentOS. I haven't been able to find a single helpful source as all the links to yum packages are not working.

Why isn't there one easy universal way to install yum like installing python libraries using pip?

This is the error that I get when I type yum on my CentOS machine:

There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:

No module named yum

Please install a package which provides this module, or
verify that the module is installed correctly.

It's possible that the above module doesn't match the
current version of Python, which is:
2.7.14 |Anaconda, Inc.| (default, Mar 27 2018, 17:29:31)
[GCC 7.2.0]

Machine Specification:

LSB Version:    :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description:    CentOS Linux release 7.4.1708 (Core)
Release:    7.4.1708
Codename:   Core

I have both two versions of python:

  1. /usr/bin/python –> python2.7
  2. output of which python is /anaconda/envs/py35/bin/python

My system seems to be confused between two python versions.

I have yum in my /usr/bin/ as ls /usr/bin/ | grep yum returns:

yum
yum-builddep
yum-config-manager
yum-debug-dump
yum-debug-restore
yumdownloader
yum-groups-manager

When I try to install a yum from yum-3.4.3-158.el7.centos.noarch.rpm using rpm -i, I get a whole lot of conflicting errors:

file /usr/lib/python2.7/site-packages/rpmUtils/__init__.pyc from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/lib/python2.7/site-packages/yum/__init__.pyc from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/lib/python2.7/site-packages/rpmUtils/arch.pyc from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/lib/python2.7/site-packages/rpmUtils/miscutils.py from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/lib/python2.7/site-packages/rpmUtils/miscutils.pyc from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/lib/python2.7/site-packages/rpmUtils/oldUtils.pyc from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/lib/python2.7/site-packages/rpmUtils/transaction.pyc from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/lib/python2.7/site-packages/rpmUtils/updates.pyc from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/lib/python2.7/site-packages/yum/Errors.py from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/lib/python2.7/site-packages/yum/Errors.pyc from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/lib/python2.7/site-packages/yum/callbacks.pyc from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/lib/python2.7/site-packages/yum/comps.pyc from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/lib/python2.7/site-packages/yum/config.py from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/lib/python2.7/site-packages/yum/config.pyc from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/lib/python2.7/site-packages/yum/constants.py from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/lib/python2.7/site-packages/yum/constants.pyc from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/lib/python2.7/site-packages/yum/depsolve.pyc from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/lib/python2.7/site-packages/yum/drpm.pyc from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/lib/python2.7/site-packages/yum/failover.pyc from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/lib/python2.7/site-packages/yum/fssnapshots.pyc from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/lib/python2.7/site-packages/yum/history.pyc from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/lib/python2.7/site-packages/yum/i18n.pyc from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/lib/python2.7/site-packages/yum/igroups.pyc from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/lib/python2.7/site-packages/yum/logginglevels.pyc from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/lib/python2.7/site-packages/yum/mdparser.pyc from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/lib/python2.7/site-packages/yum/metalink.pyc from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/lib/python2.7/site-packages/yum/misc.py from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/lib/python2.7/site-packages/yum/misc.pyc from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/lib/python2.7/site-packages/yum/packageSack.pyc from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/lib/python2.7/site-packages/yum/packages.pyc from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/lib/python2.7/site-packages/yum/parser.pyc from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/lib/python2.7/site-packages/yum/pgpmsg.pyc from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/lib/python2.7/site-packages/yum/pkgtag_db.pyc from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/lib/python2.7/site-packages/yum/plugins.pyc from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/lib/python2.7/site-packages/yum/repoMDObject.pyc from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/lib/python2.7/site-packages/yum/repos.pyc from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/lib/python2.7/site-packages/yum/rpmsack.pyc from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/lib/python2.7/site-packages/yum/rpmtrans.pyc from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/lib/python2.7/site-packages/yum/sqlitesack.pyc from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/lib/python2.7/site-packages/yum/sqlutils.pyc from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/lib/python2.7/site-packages/yum/transactioninfo.pyc from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/lib/python2.7/site-packages/yum/update_md.pyc from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/lib/python2.7/site-packages/yum/updateinfo.pyc from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/lib/python2.7/site-packages/yum/yumRepo.py from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/lib/python2.7/site-packages/yum/yumRepo.pyc from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/share/yum-cli/yummain.py from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/share/man/man5/yum.conf.5 from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/share/man/man8/yum-shell.8 from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/share/man/man8/yum.8 from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/share/yum-cli/callback.pyc from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/share/yum-cli/cli.py from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/share/yum-cli/cli.pyc from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/share/yum-cli/output.pyc from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/share/yum-cli/shell.py from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/share/yum-cli/shell.pyc from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/share/yum-cli/utils.pyc from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/share/yum-cli/yumcommands.py from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/share/yum-cli/yumcommands.pyc from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch
file /usr/share/yum-cli/yummain.pyc from install of yum-3.4.3-158.el7.centos.noarch conflicts with file from package yum-3.4.3-154.el7.centos.noarch

I have tried deleting all yum related folders from /usr/bin, /usr/lib/python2.7/site-packages, and /usr/share/ to reinstall using the above command, but it gives the same error.

Best Answer

Yum is a central part of CentOS and I don't think it's possible to have it not installed.