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.
After changing the python command, I found that the pip command also automatically changed to pip of python3, which was really embarrassing.
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'
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
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!