LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-09-2017, 06:01 AM   #1
praveenkv
LQ Newbie
 
Registered: Feb 2016
Posts: 10

Rep: Reputation: Disabled
yum not working on CentOS 6.5


when I run 'yum update', I receive following error.

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.6.6 (r266:84292, Feb 9 2017, 15:03:12)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)]

If you cannot solve this problem yourself, please go to
the yum faq at:
http://yum.baseurl.org/wiki/Faq

Please help.
 
Old 02-09-2017, 06:28 AM   #2
r3sistance
Senior Member
 
Registered: Mar 2004
Location: UK
Distribution: CentOS 6/7
Posts: 1,375

Rep: Reputation: 217Reputation: 217Reputation: 217
Have you installed another version of python by chance? I think that is what I would try, you can always scan your system to see if you have multiple versions of python with the following.

find / -type f -executable -name 'python*'
 
Old 02-09-2017, 06:34 AM   #3
praveenkv
LQ Newbie
 
Registered: Feb 2016
Posts: 10

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by r3sistance View Post
Have you installed another version of python by chance? I think that is what I would try, you can always scan your system to see if you have multiple versions of python with the following.

find / -type f -executable -name 'python*'
Oh... it seems so.
When I run that command, I see python 2.6 to 3.3 .
This is what I got.

/opt/libreoffice5.1/program/python.bin
/opt/libreoffice5.1/program/python
/usr/local/python2.6/python2.6
/usr/local/python2.6/python2.6-config
/usr/local/python2.6/python
/usr/local/lib/python3.5/config-3.5m/python-config.py
/usr/local/python2.7/bin/python2.7
/usr/local/python2.7/bin/python2.7-config
/usr/bin/bin/python3.3
/usr/bin/bin/python3.3m
/usr/bin/bin/python3.3m-config
/usr/bin/python2.6-config
/usr/lib/rpm/pythondeps.sh
/usr/lib64/gimp/2.0/plug-ins/python-eval.py
/usr/lib64/gimp/2.0/plug-ins/python-console.py
/root/Python-2.6.6/python
/root/Python-3.3.3/python
/root/Python-2.7.5/python
 
Old 02-09-2017, 06:41 AM   #4
r3sistance
Senior Member
 
Registered: Mar 2004
Location: UK
Distribution: CentOS 6/7
Posts: 1,375

Rep: Reputation: 217Reputation: 217Reputation: 217
Well first port of call, get the default python version and see if import yum works in that. If import yum fails then it ain't the right version of python we got in use.

Code:
# python -V
Python 2.7.5
# python
Python 2.7.5 (default, Sep 15 2016, 22:37:39)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import yum
>>>
this is from a CentOS 7 box, so the python version will likely differ to that of CentOS 6.

Last edited by r3sistance; 02-09-2017 at 06:47 AM. Reason: something isn't so odd actually
 
Old 02-09-2017, 06:57 AM   #5
praveenkv
LQ Newbie
 
Registered: Feb 2016
Posts: 10

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by r3sistance View Post
Well first port of call, get the default python version and see if import yum works in that. If import yum fails then it ain't the right version of python we got in use.

Code:
# python -V
Python 2.7.5
# python
Python 2.7.5 (default, Sep 15 2016, 22:37:39)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import yum
>>>
this is from a CentOS 7 box, so the python version will likely differ to that of CentOS 6.
Import yum is not working. Should I install other version of python now?

Python 2.6.6 (r266:84292, Feb 9 2017, 15:03:12)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import yum
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named yum
 
Old 02-09-2017, 07:05 AM   #6
r3sistance
Senior Member
 
Registered: Mar 2004
Location: UK
Distribution: CentOS 6/7
Posts: 1,375

Rep: Reputation: 217Reputation: 217Reputation: 217
no, the system always comes with the right version of python, we just need to check which is the right version and set yum to use that. But first let's trace what yum is using.

yum is probably using /usr/bin/python

Code:
head -n 1 /bin/yum
#!/usr/bin/python
The shebang here is important.

/usr/bin/python is usually a symbolic link, we can check that with ls -l

Code:
# ls -l /usr/bin/python
lrwxrwxrwx 1 root root 7 Oct 10 16:12 /usr/bin/python -> python2
here we go back to python2 another symbolic link

Code:
# ls -l /usr/bin/python2
lrwxrwxrwx 1 root root 9 Oct 10 16:12 /usr/bin/python2 -> python2.7
on my CentOS 7 box it points to /usr/bin/python2.7 which is where it should point for CentOS 7 and isn't a symbolic link but rather an executable

Code:
# ls -l /usr/bin/python2.7
-rwxr-xr-x 1 root root 7136 Sep 15 23:38 /usr/bin/python2.7
Can you trace back where yum is looking at for an executable? if I remember correctly for CentOS 6, it should be /usr/bin/python2.6

Last edited by r3sistance; 02-09-2017 at 07:34 AM. Reason: misread
 
Old 02-09-2017, 07:38 AM   #7
praveenkv
LQ Newbie
 
Registered: Feb 2016
Posts: 10

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by r3sistance View Post
no, the system always comes with the right version of python, we just need to check which is the right version and set yum to use that. But first let's trace what yum is using.

yum is probably using /usr/bin/python

Code:
head -n 1 /bin/yum
#!/usr/bin/python
Code:
# head -n 1 /bin/yum
head: cannot open `/bin/yum' for reading: No such file or directory
The shebang here is important.

/usr/bin/python is usually a symbolic link, we can check that with ls -l

Code:
# ls -l /usr/bin/python
lrwxrwxrwx 1 root root 7 Oct 10 16:12 /usr/bin/python -> python2
Code:
# ls -l /usr/bin/python
lrwxrwxrwx 1 root root 27 Feb  9 16:30 /usr/bin/python -> /usr/local/python2.6/python
In my case, it's going to python again. Should I change it to python2 using
Code:
mv
?

here we go back to python2 another symbolic link

Code:
# ls -l /usr/bin/python2
lrwxrwxrwx 1 root root 9 Oct 10 16:12 /usr/bin/python2 -> python2.7
on my CentOS 7 box it points to /usr/bin/python2.7 which is where it should point for CentOS 7 and isn't a symbolic link but rather an executable

Code:
# ls -l /usr/bin/python2.7
-rwxr-xr-x 1 root root 7136 Sep 15 23:38 /usr/bin/python2.7
Can you trace back where yum is looking at for an executable? if I remember correctly for CentOS 6, it should be /usr/bin/python2.6
Are the different versions of pythons clashing?
 
Old 02-09-2017, 07:42 AM   #8
r3sistance
Senior Member
 
Registered: Mar 2004
Location: UK
Distribution: CentOS 6/7
Posts: 1,375

Rep: Reputation: 217Reputation: 217Reputation: 217
I suspect something has changed the location /usr/bin/python points too, /usr/bin/python needs to point at a specific version of python. So the issue is, it is loading the wrong version but the fix is simply to re-align /usr/bin/python to point back at the right version. So if you can give the output of the following I think I will be able to confirm the exactly issue.

# ls -l /usr/bin | grep python
 
Old 02-09-2017, 10:17 AM   #9
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Quote:
Originally Posted by praveenkv View Post
Oh... it seems so.
When I run that command, I see python 2.6 to 3.3 .
Never ever ever install any version of python other than the default one on a CentOS/RHEL system (unless you put it somewhere completely separate, like your home directory). It's a very easy way to brick yum, and it can be very hard to come back from.
 
Old 02-09-2017, 10:45 AM   #10
r3sistance
Senior Member
 
Registered: Mar 2004
Location: UK
Distribution: CentOS 6/7
Posts: 1,375

Rep: Reputation: 217Reputation: 217Reputation: 217
Quote:
Originally Posted by suicidaleggroll View Post
Never ever ever install any version of python other than the default one on a CentOS/RHEL system (unless you put it somewhere completely separate, like your home directory). It's a very easy way to brick yum, and it can be very hard to come back from.
I was hoping/thinking in this case python can be fixed by changing the shebang in /bin/yum to #!/usr/bin/python2.6. If not, then praveenkv is going to have a very painful time here indeed. Naturally was trying to get the evidence to support my theory before actually making such changes. But yeah, Python isn't something to play around with in RHEL and RHEL based systems...

Last edited by r3sistance; 02-09-2017 at 10:46 AM.
 
Old 02-09-2017, 02:58 PM   #11
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,624

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
you are aware that 6.5 is UNSUPPORTED and that the repos were moved to the historical archive " the vault"
there are NO updates for
CentOS 6.5
CentOS 6.6
CentOS 6.7
however not all the mirrors might have been deleted , but they are 2 years OUT OF DATE

CentOS 6.8 is the current and ONLY minor version supported

please check the version you are running
Code:
su -
cat /etc/redhat_release
and make sure that states it is 6.8


as to different versions
that SHOULD be a no
BUT it depends on HOW 3.3 was installed

you can have many different versions installed "side by side" but you CAN NOT!!! replace the default version
 
Old 02-09-2017, 10:16 PM   #12
praveenkv
LQ Newbie
 
Registered: Feb 2016
Posts: 10

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by r3sistance View Post
I suspect something has changed the location /usr/bin/python points too, /usr/bin/python needs to point at a specific version of python. So the issue is, it is loading the wrong version but the fix is simply to re-align /usr/bin/python to point back at the right version. So if you can give the output of the following I think I will be able to confirm the exactly issue.

# ls -l /usr/bin | grep python
This is the response.

# ls -l /usr/bin | grep python
-rwxr-xr-x 1 root root 20152 May 11 2016 abrt-action-analyze-python
lrwxrwxrwx 1 root root 48 Feb 7 16:50 kid -> ../../usr/lib/python2.6/site-packages/kid/run.py
lrwxrwxrwx 1 root root 52 Feb 7 16:50 kidc -> ../../usr/lib/python2.6/site-packages/kid/compile.py
lrwxrwxrwx 1 root root 27 Feb 9 16:30 python -> /usr/local/python2.6/python
-rwxr-xr-x. 1 root root 1418 Aug 18 21:07 python2.6-config
lrwxrwxrwx. 1 root root 16 Oct 18 12:10 python-config -> python2.6-config
-rwxr-xr-x. 1 root root 14954 Aug 17 2012 qpid-python-test
You have new mail in /var/spool/mail/root
 
Old 02-09-2017, 10:19 PM   #13
praveenkv
LQ Newbie
 
Registered: Feb 2016
Posts: 10

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by John VV View Post
you are aware that 6.5 is UNSUPPORTED and that the repos were moved to the historical archive " the vault"
there are NO updates for
CentOS 6.5
CentOS 6.6
CentOS 6.7
however not all the mirrors might have been deleted , but they are 2 years OUT OF DATE

CentOS 6.8 is the current and ONLY minor version supported

please check the version you are running
Code:
su -
cat /etc/redhat_release
and make sure that states it is 6.8


as to different versions
that SHOULD be a no
BUT it depends on HOW 3.3 was installed

you can have many different versions installed "side by side" but you CAN NOT!!! replace the default version
Yes it is saying 6.8. So, am I using CentOS 6.8 and not 6.5??
Red Hat Enterprise Linux Server release 6.8 (Santiago)
 
Old 02-10-2017, 03:31 AM   #14
r3sistance
Senior Member
 
Registered: Mar 2004
Location: UK
Distribution: CentOS 6/7
Posts: 1,375

Rep: Reputation: 217Reputation: 217Reputation: 217
oh no... where is /usr/bin/python2 and /usr/bin/python2.6 gone? Well hopefully you have wget.

If you do, then the following maybe an option

Code:
wget http://mirror.centos.org/centos/6.8/os/x86_64/Packages/python-2.6.6-64.el6.x86_64.rpm
rpm -iv --force python-2.6.6-64.el6.x86_64.rpm
But I am not certain if that is enough, recovering python from this point is going to be extremely difficult. If the box isn't very important then I'd definitely recommend re-installing CentOS by this point.

Last edited by r3sistance; 02-10-2017 at 03:33 AM. Reason: disabling link parsing
 
Old 02-10-2017, 05:40 AM   #15
praveenkv
LQ Newbie
 
Registered: Feb 2016
Posts: 10

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by r3sistance View Post
oh no... where is /usr/bin/python2 and /usr/bin/python2.6 gone? Well hopefully you have wget.

If you do, then the following maybe an option

Code:
wget http://mirror.centos.org/centos/6.8/os/x86_64/Packages/python-2.6.6-64.el6.x86_64.rpm
rpm -iv --force python-2.6.6-64.el6.x86_64.rpm
But I am not certain if that is enough, recovering python from this point is going to be extremely difficult. If the box isn't very important then I'd definitely recommend re-installing CentOS by this point.
Code:
# wget http://mirror.centos.org/centos/6.8/os/x86_64/Packages/python-2.6.6-64.el6.x86_64.rpm
--2017-02-10 17:01:08-- http://mirror.centos.org/centos/6.8/...el6.x86_64.rpm
Resolving mirror.centos.org... 202.76.233.2, 2605:9000:401:102::2
Connecting to mirror.centos.org|202.76.233.2|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 77464 (76K) [application/x-rpm]
Saving to: “python-2.6.6-64.el6.x86_64.rpm”

100%[===============================================================>] 77,464 98.2K/s in 0.8s

2017-02-10 17:01:09 (98.2 KB/s) - “python-2.6.6-64.el6.x86_64.rpm” saved [77464/77464]


Code:
# rpm -iv --force python-2.6.6-64.el6.x86_64.rpm
error: Failed dependencies:
python-libs(x86-64) = 2.6.6-64.el6 is needed by python-2.6.6-64.el6.x86_64
python = 2.6.6-66.0.1.el6_8 is needed by python-devel-2.6.6-66.0.1.el6_8.x86_64
python < 2.6.6-66.0.1.el6_8 conflicts with python-devel-2.6.6-66.0.1.el6_8.x86_64

What does this mean?
Is there no alternative than re-installing the OS?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Wifi stopped working after yum update - CentOS 7 aocferreira Linux - Wireless Networking 7 07-22-2015 01:34 PM
[SOLVED] yum-cron is not working on CentOS 5.10 kkpal Linux - Server 4 05-26-2014 11:15 PM
yum repolist issue (yum not working on Centos 5) sanjay2004 Programming 10 02-26-2014 05:57 AM
Yum Not working in CentOS 6.4 mahesh1222 Linux - Distributions 10 01-15-2014 03:09 AM
yum not working on centos 5 vivendi Linux - Newbie 6 11-17-2011 04:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:37 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration