Example of how to modify Python commands under Linux (with code)

不言
Release: 2018-12-12 09:53:29
forward
2725 people have browsed it

This article brings you an example of how to modify Python commands under Linux (with code). It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

The default python command in Linux points to python under /usr/bin. This python points to python2 in the same directory, and pip defaults to pip of python2. If you want to change pip to point to pip3, start the operation. .

Delete the original python command (you can back it up first, because I am purely experimenting and feel free to do so), and copy the python35 link file to python.

Example of how to modify Python commands under Linux (with code)

After changing the python command, I found that the pip command also automatically changed to pip of python3, which was really embarrassing.

Example of how to modify Python commands under Linux (with code)

By the way, it is really convenient to download the Linux pipeline command:

There are many files under /usr/bin, I only care about it How to create a file with python in its name?

ll | grep -n 'python'
Copy after login

Example of how to modify Python commands under Linux (with code)

When changing the python command from python2 to python3, you will encounter an error when using yum:

File "/usr/bin/yum", line 30 except KeyboardInterrupt, e:
Copy after login

Cause:

Yum package management is written using python2. After upgrading python2 to python3, problems will occur due to the syntax compatibility of the python version.

Solution: Just modify the corresponding configuration file of yum!

vi /usr/bin/yum
#!/usr/bin/python
Copy after login

Modify to

#!/usr/bin/python2
Copy after login
Copy after login

Example of how to modify Python commands under Linux (with code)

Modify the urlgrabber-ext-down file and change the python version

#!/usr/bin/python
Copy after login

Modify Cheng

#!/usr/bin/python2
Copy after login
Copy after login

The above is the detailed content of Example of how to modify Python commands under Linux (with code). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:segmentfault.com
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