Home  >  Article  >  Backend Development  >  Example of how to modify Python commands under Linux (with code)

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

不言
不言forward
2018-12-12 09:53:292730browse

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'

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:

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

Modify to

#!/usr/bin/python2

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

Modify Cheng

#!/usr/bin/python2

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!

Statement:
This article is reproduced at:segmentfault.com. If there is any infringement, please contact admin@php.cn delete