当系统中存在python2 和python3 两个版本时如何管理切换python版本
root@ubuntu:/home/q# update-alternatives –list python
update-alternatives: error: no alternatives for python
root@ubuntu:/home/q# update-alternatives –install /usr/bin/python python /usr/bin/python2.7
python2.7 python2.7-config
root@ubuntu:/home/q# update-alternatives –install /usr/bin/python python /usr/bin/python2.7 1
update-alternatives: using /usr/bin/python2.7 to provide /usr/bin/python (python) in auto mode
root@ubuntu:/home/q# update-alternatives –install /usr/bin/python python /usr/bin/python3.
python3.6 python3.6m python3.7 python3.7m
root@ubuntu:/home/q# update-alternatives –install /usr/bin/python python /usr/bin/python3.7 2
update-alternatives: using /usr/bin/python3.7 to provide /usr/bin/python (python) in auto mode
root@ubuntu:/home/q# update-alternatives –list python
/usr/bin/python2.7
/usr/bin/python3.7
root@ubuntu:/home/q# update-alternatives –config python
There are 2 choices for the alternative python (providing /usr/bin/python).
Selection Path Priority Status
0 /usr/bin/python3.7 2 auto mode
1 /usr/bin/python2.7 1 manual mode
2 /usr/bin/python3.7 2 manual mode
Press to keep the current choice[*], or type selection number: 2
root@ubuntu:/home/q# python –version
Python 3.7.1
root@ubuntu:/home/q# update-alternatives –remove python /usr/bin/python2.7
root@ubuntu:/home/q# update-alternatives –install /usr/bin/python python /usr/bin/python2.7 1
root@ubuntu:/home/q# update-alternatives –config python
There are 2 choices for the alternative python (providing /usr/bin/python).
Selection Path Priority Status
0 /usr/bin/python3.7 2 auto mode
1 /usr/bin/python2.7 1 manual mode
2 /usr/bin/python3.7 2 manual mode
Press to keep the current choice[*], or type selection number: