Yum not working after update - python

How do I resolve this error. Can anyone help to find this?
sudo yum groupinstall -y 'development tools'
Got following error:
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:
/usr/lib/librpm.so.3: undefined symbol: selinux_status_close
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.9 (unknown, Sep 13 2014, 00:25:13)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-16)]
If you cannot solve this problem yourself, please go to
the yum faq at:
http://yum.baseurl.org/wiki/Faq

Related

"No module named yum" centos7

my OS is CentOS Linux release 7.4.1708
First,I install anaconda for python.then I replace the default python in /usr/bin/python.
$ ll /usr/bin/python*
lrwxrwxrwx. 1 root root 7 Aug 15 03:40 /usr/bin/python -> python2
lrwxrwxrwx. 1 root root 9 Aug 9 22:10 /usr/bin/python3 -> python3.6
lrwxrwxrwx. 1 root root 29 Aug 9 22:10 /usr/bin/python2.7 -> /root/anaconda2/bin/python2.7
lrwxrwxrwx. 1 root root 29 Aug 9 21:59 /usr/bin/python3.6 -> /root/anaconda3/bin/python3.6
lrwxrwxrwx. 1 root root 9 Aug 8 23:49 /usr/bin/python2 -> python2.7
Python 2.7.15 |Anaconda, Inc.| (default, May 1 2018, 23:32:55)
[GCC 7.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
so I can't use yum any more.
$ yum
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.15 |Anaconda, Inc.| (default, May 1 2018, 23:32:55)
[GCC 7.2.0]
If you cannot solve this problem yourself, please go to
the yum faq at:
http://yum.baseurl.org/wiki/Faq
I'm try to fix vi /usr/bin/yum the first line to any other python path.
but it doesn't work.
also,I'm trying to reinstall python*.rpm like this:
rpm -ivh python-tools-2.7.5-68.el7.x86_64.rpm python-2.7.5-68.el7.x86_64.rpm python-libs-2.7.5-68.el7.x86_64.rpm tkinter-2.7.5-68.el7.x86_64.rpm
and reinstall yum*.rpm (I download a lot of *.rpm today...)
but, still not work.
anyone give me a hand? thanks!
I got this problem on CentOS7 with Yum3.4.3, Python2.7.5 recently,
[root#centos64b build]# yum list 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.5 (default, Apr 11 2018, 07:36:10) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]
If you cannot solve this problem yourself, please go to the yum faq
at: http://yum.baseurl.org/wiki/Faq
While I did not update Python before I met this problem. Finally it is found that python site-packages libpath was not set in sys.path, so the fix here is to append the site-package libpath to sys.path in /usr/bin/yum Python script. Then yum works fine.
[build#centos64b ~]$ more /usr/bin/yum
#!/usr/bin/python
import sys
sys.path.append('/usr/lib/python2.7/site-packages')
sys.path.append('/usr/lib64/python2.7/site-packages')
I found two solution for the problem on Superuser StackExchange
Solution 1
ln -s /etc/yum.conf /etc/yum/yum.conf
Solution 2
Remove newly installed python
rm /usr/bin/python
Link python with the correct version (x.y)
ln -s /usr/bin/pythonx.y /usr/bin/python
Reinstall python with
rpm -ivh --force python-2.7.5-68.el7.x86_64.rpm
Why it works. Generally rpm is tolerant to files of other packages. In your case it sees that it didn't create the link files so it skipped them on install. From man rpm
we can find
--force
Same as using --replacepkgs, --replacefiles, and --oldpackage.
--replacefiles
Install the packages even if they replace files from other, already installed, packages.
With these options rpm does not care about the fact, that old files were created by someone else.
P.S. Some tips: never remove change files in /usr/bin. /bin is better place for your links. Even better add your bin directory to $PATH by adding to your .bash_profile something like this:
$PATH=/root/anaconda2/bin/python2.7:$PATH
So if something breaks, it's just a matter of removing the line from .bash_profile.
And once more: always do backups, especially when working with system files.

Python 3.5 error "No module named '_tkinter'", but tkinter is installed. Happened after installing new graphics card and cuda driver

I just installed a nvidia and cuda driver. After that a python program that was running before now gives the error "No module named '_tkinter'"
I use python 3.5 and "import tkinter" now results in the same error.
"sudo apt-get install python3-tk" results in "python3-tk is already the newest version". So somehow tkinter is available but not seen...
Any idea what I can do? I also have python3.6 installed. Maybe any wrong configuration...?
python3
Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
import site; site.getsitepackages()
['/usr/local/lib/python3.5/dist-packages', '/usr/lib/python3/dist packages', '/usr/lib/python3.5/dist-packages']
which -a python3
/usr/bin/python3
The python3-tk package is a virtual package which refers to the specific 3.x version e.g. python3.5-tk or python3.6-tk.
Since you said you have also installed python 3.6, Do you see the same error message if you try running the application with Python 3.6 ? You may have to change your path to refer to your python 3.6 environment or just use virtualenv before invoking your application.
# You can also try this:
sudo apt install python3.5-tk

"No module named yum" with Python 2.7

I need to use Python 2.7 for my project. But after installing Python, I can't use the module yum. I have this error :
[root#nexus-chat2 .synapse]# yum
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.5 (default, Feb 19 2018, 14:55:04)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-18)]
If you cannot solve this problem yourself, please go to
the yum faq at:
http://yum.baseurl.org/wiki/Faq
Do you know how can I fix that ? I use CentOS 6
The yum module is not a stock Python module. It would need to be built and installed explicitly for any version of Python you install on your system. With CentOS 6, the system Python is python 2.6 (and the yum module will be available by default).
If you wanted to make the yum module available to your Python 2.7 install, you would need to build yum against your Python 2.7 install, which may be a non-trivial task.
The simplest solutions are (a) just use Python 2.6 or (b) upgrade to a more recent distribution.

There was a error importing one of the Python modules

I am trying to run a yum command # yum install mod-pagespeed but I am getting this error
There was a problem importing one of the Python modules required to
run yum. The error leading to this problem was:
cannot import name Repository
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 22 2013, 00:00:18) [GCC 4.4.7 20120313 (Red Hat 4.4.7-3)]
If you cannot solve this problem yourself, please go to the yum faq
at: http://yum.baseurl.org/wiki/Faq
Your help will be greatly appreciated
Did you upgrade the Python that's running on your system? It's possible that it broke yum, as yum on older systems relied on the Python version being 2.4
Can you downgrade python back to 2.4 to get yum working again, then do an alternate install of Python to a newer version, keeping both on your system?
See this link for procedures for installing alternate versions of python:
https://github.com/h2oai/h2o-2/wiki/Installing-python-2.7-on-centos-6.3.-Follow-this-sequence-exactly-for-centos-machine-only

yum install error Centos 5

I cannot find any information regarding the issue I am having so here it is.
While trying to yum install php-pear (infact running yum at all) I run into this problem:
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:
cannot import name canCoinstall
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.4.3 (#1, Nov 11 2010, 13:34:43)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-48)]
If you cannot solve this problem yourself, please go to
the yum faq at:
http://wiki.linux.duke.edu/YumFaq
And as it says above - something to do with the module canCoinstall. Does anyone know how I can fix this?
change your python version in yum to lower,
such as:/etc/bin/yum
change
#!/usr/bin/python
to
#!/usr/bin/python2.4

Categories