Solution for python error while using yum install

In this guide we are about to see how to resolve the python error while using all yum command such as install, remove some package.

Reason of this error is because of Library path conflict with libPython(version).so.

Below error output truncated due to long output.

root@proappserver ~]# yum install iptraf
Plugin "refresh-packagekit" can't be imported
Loaded plugins: security
local_oel6.5 | 3.7 kB 00:00
Traceback (most recent call last):
 File "/usr/bin/yum", line 29, in <module>
 yummain.user_main(sys.argv[1:], exit_code=True)
 File "/usr/share/yum-cli/yummain.py", line 285, in user_main
 errcode = main(args)
 File "/usr/share/yum-cli/yummain.py", line 136, in main
 result, resultmsgs = base.doCommands()
import cElementTree
ImportError: No module named cElementTree

List the current Library path using echo, and unset the library path.

[root@proappserver ~]# echo $LD_LIBRARY_PATH
/usr/lib:/home/oracle/app/oracle/product/11.2.0/client_1/lib

[root@proappserver ~]# unset LD_LIBRARY_PATH

Then run the yum install or remove command without python error.

Below output truncated.

[root@proappserver ~]# yum remove rhn-check.noarch rhn-setup.noarch rhn-setup-gnome.noarch rhnlib.noarch
Loaded plugins: refresh-packagekit, security
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package rhn-check.noarch 0:1.0.0-87.0.2.el6 will be erased
---> Package rhnsd.x86_64 0:4.9.3-2.0.1.el6 will be erased
---> Package yum-rhn-plugin.noarch 0:0.9.1-40.0.1.el6 will be erased
--> Finished Dependency Resolution
local_oel6.5 | 3.7 kB 00:00
local_oel6.5/primary_db | 3.1 MB 00:02
local_spacewalk22 | 951 B 00:00
Dependencies Resolved
========================================================================================================================================
 Package Arch Version Repository Size
========================================================================================================================================
Removing:
 rhn-check noarch 1.0.0-87.0.2.el6 @anaconda-OracleLinuxServer-201206261930.x86_64/6.3 42 k
 rhn-setup noarch 1.0.0-87.0.2.el6 @anaconda-OracleLinuxServer-201206261930.x86_64/6.3 213 k
 rhn-setup-gnome noarch 1.0.0-87.0.2.el6 @anaconda-OracleLinuxServer-201206261930.x86_64/6.3 426 k
Transaction Summary
========================================================================================================================================
Remove 7 Package(s)
Installed size: 3.8 M
Is this ok [y/N]: y
Warning: RPMDB altered outside of yum.
 Erasing : rhn-setup-gnome-1.0.0-87.0.2.el6.noarch 1/7
 Erasing : rhnsd-4.9.3-2.0.1.el6.x86_64 2/7
 Verifying : rhn-setup-1.0.0-87.0.2.el6.noarch 5/7

Removed:
 rhn-check.noarch 0:1.0.0-87.0.2.el6 rhn-setup.noarch 0:1.0.0-87.0.2.el6 rhn-setup-gnome.noarch 0:1.0.0-87.0.2.el6
 rhnlib.noarch 0:2.5.22-12.0.2.el6

Dependency Removed:
 rhn-client-tools.noarch 0:1.0.0-87.0.2.el6 rhnsd.x86_64 0:4.9.3-2.0.1.el6 yum-rhn-plugin.noarch 0:0.9.1-40.0.1.el6

Complete!
[root@proappserver ~]#

Just by unsetting library path Python will look for only one library path which will be free from conflict.