#当未设置python不同版本的优先级时,执行切换命令返回错误提示 root@nj:~# update-alternatives --config python update-alternatives: error: no alternatives for python
#设置python不同版本的优先级 root@nj:~# 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@nj:~# update-alternatives --install /usr/bin/python python /usr/bin/python3.9 2 update-alternatives: using /usr/bin/python3.9 to provide /usr/bin/python (python) in auto mode
#切换 root@nj:~# update-alternatives --config python There are 2 choices for the alternative python (providing /usr/bin/python).
Press <enter> to keep the current choice[*], or type selection number: 1 update-alternatives: using /usr/bin/python2.7 to provide /usr/bin/python (python) in manual mode root@nj:~# python -V Python 2.7.18
#1 python2.7 #2 python3.9
pip如何共存呢,安装python3.9后默认指向的是pip3,并且pip2命令是不存在的
1 2 3 4 5 6 7 8 9 10 11
root@nj:~# pip -V pip 23.1.2 from /usr/local/lib/python3.9/dist-packages/pip (python 3.9) root@nj:~# pip3 -V pip 23.1.2 from /usr/local/lib/python3.9/dist-packages/pip (python 3.9) root@nj:~# pip3.9 -V pip 23.1.2 from /usr/local/lib/python3.9/dist-packages/pip (python 3.9)
root@nj:~# pip2 -V -bash: pip2: command not found root@nj:~# pip2.7 -V -bash: pip2.7: command not found