How to solve the problem of yum and pip errors caused by Python upgrade

巴扎黑
Release: 2017-09-07 09:43:08
Original
2035 people have browsed it

This article mainly introduces to you the solution to the error reported by yum and pip due to Python upgrade. The solution is introduced in great detail through sample code. It has certain reference learning value for everyone's study or work. It needs Friends, please follow the editor to learn together.

Preface

This article mainly introduces how to solve the problem of yum and pip errors caused by Python upgrade, and shares it for your reference and study. Not much to say below, let’s take a look at the detailed introduction.

Reason:

yum is written in Python. The Python version on the server is too low and has been upgraded to 2.7, but yum/pip has not been upgraded, resulting in this error being reported when executing yum/pip.

yum reported an 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.7.10 (default, Sep 5 2017, 17:35:43) 
[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
Copy after login

pip reported an error:


Traceback (most recent call last):
 File "/usr/bin/pip2", line 5, in <module>
 from pkg_resources import load_entry_point
ImportError: No module named pkg_resources
Copy after login

Solution:

1. Check the Python version and execute:


which python
Copy after login

You can see that there are two versions of Python.

2. View the yum file and execute:


vim /usr/bin/yum
Copy after login

You can see the Python reference of yum in the first line of the file. Change the original #!/usr/bin/python to #!/usr/bin/python2.6 (old version)

3. Jump out and execute yum again. Ready to use.

pip is modified in the same way

The above is the detailed content of How to solve the problem of yum and pip errors caused by Python upgrade. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!