Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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)]
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.
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.
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
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
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
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
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.
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.
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.
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
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
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)
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
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.
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?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.