- Centos 7 no module named yum
- «No module named yum» centos7
- Solution 1
- Solution 2
- Centos 7 — No module named yum — Accidentally removed Python site-packages
- Yum Error: No module named site
- «No module named yum» with Python 2.7
- Why yum/subscription-manager/sosreport fail on system with «No module named. » error ?
- Root Cause
- Diagnostic Steps
Centos 7 no module named yum
With CentOS 6, the system Python is python 2.6 (and the module will be available by default). Generally rpm is tolerant to files of other packages.
«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
Solution 2
Remove newly installed python
Link python with the correct version (x.y)
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 — «No module named yum» centos7, 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 … Code sample[build@centos64b ~]$ more /usr/bin/yum#!/usr/bin/pythonimport syssys.path.append(‘/usr/lib/python2.7/site-packages’)sys.path.append(‘/usr/lib64/python2.7/site-packages’)Feedback
Centos 7 — No module named yum — Accidentally removed Python site-packages
I accidentally removed my Python’s site-packages which means I got no any modules. Unfortunately, I noticed too late that the Yum uses a module named yum which is installed in the Python’s site-packages where is located in /usr/local/lib/python2.7/site-packages . I was trying to reinstall yum but no yum module was installed.
Hope to find an answer, thanks!
I fixed this issue by installing CentOS on a VM and then scp the python2.7 directory to the server.
Try rpm -V yum which checks for issues with yum
Yum not found on Centos 7 » No module named yum», Yum not found on Centos 7 » No module named yum» Ask Question Asked 3 years, 8 months ago. Modified 3 years, 8 months ago. Viewed …
Yum Error: No module named site
I installed Greenplum on Centos 7 and now I cannot use yum.
I need to install samba-client but when I run:
I see this error: ImportError: No module named site
which python /usr/local/greenplum-db/ext/python/bin/python python -V Python 2.6.2 cat $PYTHONHOME cat: /usr/local/greenplum-db/./ext/python: Is a directory
No idea how this happened. I notice that my other servers do not have this problem and display python 2.7.5
Change the location of the standard Python libraries. By default, the libraries are searched in prefix/lib/pythonversion and exec_prefix/lib/pythonversion, where prefix and exec_prefix are installation-dependent directories, both defaulting to /usr/local.
When pythonhome is set to a single directory, its value replaces both prefix and exec_prefix. To specify different values for these, set PYTHONHOME to prefix:exec_prefix.
In a shell you can use these commands to clean up those :
unset PYTHONPATH ## to use the system default ## unset PYTHONHOME
Python — Centos — No module named yum, We will use Debian 11, not CentOS. CentOS 7 is really old. It needs to be noted that this problem would not occur, if the new Python would be …
«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.
Centos 7 — No module named yum, Unfortunately, I noticed too late that the Yum uses a module named yum which is installed in the Python’s site-pac Stack Overflow. About; …
Why yum/subscription-manager/sosreport fail on system with «No module named. » error ?
Resolution 1
* Unset the PYTHONHOME variable:
- For permanent change remove entry from root’s .bashrc or .bash_profile if present.
- Reinstall python package by running following command:
# rpm -Uvh --replacefiles --replacepkgs python-.rpm
Resolution 2
* If there is no PYTHONHOME variable set, check to ensure there is no third-party python located underneath the improper /lib/ location instead of /lib64/ .
* Check the python path as well as ldd to see which files are being loaded:
# python -c "import sys; print(sys.path)" ['', '/usr/lib64/python27.zip', '/usr/lib64/python2.7', '/usr/lib64/python2.7/plat-linux2', '/usr/lib64/python2.7/lib-tk', '/usr/lib64/python2.7/lib-old', '/usr/lib64/python2.7/lib-dynload', '/usr/lib64/python2.7/site-packages', '/usr/lib/python2.7/site-packages'] # ldd /usr/bin/python linux-vdso.so.1 => (0x00007ffd46b3b000) libpython2.7.so.1.0 => /lib64/libpython2.7.so.1.0 (0x00007efe38aaf000) /lib64/libpthread.so.0 (0x00007efe38893000) libdl.so.2 => /lib64/libdl.so.2 (0x00007efe3868f000) libutil.so.1 => /lib64/libutil.so.1 (0x00007efe3848c000) libm.so.6 => /lib64/libm.so.6 (0x00007efe3818a000) libc.so.6 => /lib64/libc.so.6 (0x00007efe37dbc000) /lib64/ld-linux-x86-64.so.2 (0x00007efe38e7b000)
- The above output indicates what is expected. If you see /usr/lib/python2.7 being loaded instead of /usr/lib64/python2.7 you should check the following:
# ls -l /lib/libpython2.7.so.1.0 # rpm -qf /lib/libpython2.7.so.1.0
- If you find that there is a file at /lib/libpython2.7.so.1.0 and it is not owned by any package, you should move that file aside and see if the issue remains:
# mv /lib/libpython2.7.so.1.0 /tmp/
- The prioritized python can also be in /root/.local , thus please ensure that there is no python under this path.
Root Cause
- PYTHONHOME variable was set as environment variable on system.
- Python libraries/files are modified which can be observed from output of rpm -Va command.
- Third party python modules are installed on system which found in output of ldd /usr/bin/python command.
- The package rpm-python* is not installed.
- There is a third-party /lib/libpython2.7.so.1.0 that is being loaded instead of the proper system location of /lib64/libpython2.7.so.1.0. This causes the python module search path defined by sys.path to be incorrectly set, resulting in the system not finding the installed python modules
Diagnostic Steps
# sosreport 'import site' failed; use -v for traceback Traceback (most recent call last): File "/usr/sbin/sosreport", line 29, in ? import os ImportError: No module named os # yum -d10 update 'import site' failed; use -v for traceback 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.4.3 (#1, Jul 16 2009, 06:20:46) [GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] If you cannot solve this problem yourself, please go to the yum faq at: http://wiki.linux.duke.edu/YumFaq
Collect the following details from system
# rpm -qa --queryformat "%-%-%-%\n" | sort > /tmp/rpm-list # ldd /usr/bin/python Strace command output # strace -fttTvyyo /tmp/strace.out -s 4096 yum update # which python # env > /tmp/env.out # rpm -qf `which yum` # rpm -Va > /tmp/rpm_va
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.