Solved the problem that yum cannot be used correctly after upgrading Python to version 3.6 in CentOS7. centos7yum

Source: Internet
Author: User

Solved the problem that yum cannot be used correctly after upgrading Python to version 3.6 in CentOS7. centos7yum

After we upgraded the existing Alibaba CentOS7.2 system's Python2.7.5 to Python3.6, the yum tool could not be used. At that time, I checked and explained the problem of the python version, but I still did not solve the problem using the online method, and I still had to worry about it later. To get a node. js applet recently, you need to install some development tools using yum and have to fix this problem.

 

1 yum tool Error

If you directly execute the yum command, an error occurs in line 34th of the/usr/bin/yum file:

[root@typecodes ~]# yumFile "/usr/bin/yum", line 34 ^SyntaxError: EOF while scanning triple-quoted string literal[root@typecodes ~]#

But vim does not check this line at all for this file:

 

2 solution

Because the error location cannot be found, you can only consider re-installing yum.

 

2.1 Download the yum installation package
[root@typecodes ~]# wget -c http://yum.baseurl.org/download/3.4/yum-3.4.3.tar.gz[root@typecodes ~]# tar -zxf yum-3.4.3.tar.gz[root@typecodes ~]# cd yum-3.4.3/

Usepython2 yummain.py install yum Command (or you cannot use python3 for execution) to reinstall the yum tool:

 

2.2 run the yum command

If you try to run the yum command, the following error occurs in the 30th line of the/usr/bin/yum file:

[root@typecodes yum-3.4.3]# yumFile "/usr/bin/yum", line 30 except KeyboardInterrupt, e:       ^SyntaxError: invalid syntax[root@typecodes yum-3.4.3]#

Obviously, the above counter T is written in python2. Of course, the default Python3 cannot be used for execution. Therefore, the 1st rows of the file#!/usr/bin/python Replace#!/usr/bin/python2.

2.2 continue executing the yum command

Try to executeyum -y update Command to update the CentOS system. /usr/libexec/urlgrabber-ext-down 28th line or reportSyntaxError: invalid syntax.

 

The problem is the same, either/usr/libexec/urlgrabber-ext-down In the file, replace all the counter t statements with Python3, or modify the interpreter declaration of Line 1. Obviously, the update of the 2nd methods is simple and effective.

3 solved

This makes it easy to use. yum -y update Command to update the CentOS system, and then develop it!

 

Summary

The above section describes how to fix the problem that yum cannot be used correctly after CentOS7 is upgraded to Python 3.6. I hope it will help you. If you have any questions, please leave a message, the editor will reply to you in a timely manner. Thank you very much for your support for the help House website!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.