


How to solve the problem of yum and pip errors caused by Python upgrade
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
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
Solution:
1. Check the Python version and execute:
which python
You can see that there are two versions of Python.
2. View the yum file and execute:
vim /usr/bin/yum
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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Solution to permission issues when viewing Python version in Linux terminal When you try to view Python version in Linux terminal, enter python...

When using Python's pandas library, how to copy whole columns between two DataFrames with different structures is a common problem. Suppose we have two Dats...

Getting started with Python: Hourglass Graphic Drawing and Input Verification This article will solve the variable definition problem encountered by a Python novice in the hourglass Graphic Drawing Program. Code...

How do Python scripts clear output to cursor position at a specific location? When writing Python scripts, it is common to clear the previous output to the cursor position...

Choice of Python Cross-platform desktop application development library Many Python developers want to develop desktop applications that can run on both Windows and Linux systems...

Alternative usage of Python parameter annotations In Python programming, parameter annotations are a very useful function that can help developers better understand and use functions...

In Python, how to dynamically create an object through a string and call its methods? This is a common programming requirement, especially if it needs to be configured or run...

Many developers rely on PyPI (PythonPackageIndex)...
