In rare occassions you may have an error such as "is a duplicate with". In such case, you will need to remove the duplicates from yum. Here is an example error in yum:

yum-3.4.3-158.el7.centos.noarch is a duplicate with yum-3.4.3-154.el7.centos.1.noarch
yum-plugin-fastestmirror-1.1.31-45.el7.noarch is a duplicate with yum-plugin-fastestmirror-1.1.31-42.el7.noarch

NOTE As always, create a backup before running the commands below.

Make sure that you have yum-utils installed before you continue:

yum install yum-utils -y

The following command resolves this issue:

package-cleanup —cleandupes

Depending on your situation, you may get the following error:

Warning: Some duplicates were not removed because they are required by installed packages.
You can try —cleandupes without --removenewestdupes, or review them with --dupes and remove manually.

To resolve this, execute the following command:

package-cleanup --cleandupes --removenewestdupes

If this command still shows errors, you can try to reinstall the packages. Replace packagename with the actual packagename you want to reinstall.

yum reinstall packagename