Pythonのカットバージョン

python2はのpython3を切り替えます

sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 100
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 150

上記二つのコマンドの実装はpython3.6バージョン2.7バージョンに切り替えることができ、あなたは成功を切り替えるかどうかを確認したいです。

shanlei@shanlei-Lenovo-ideapad-110-15ISK:~$ python --version
Python 3.6.5
shanlei@shanlei-Lenovo-ideapad-110-15ISK:~$ 

python3はpython2を切り替えます

shanlei@shanlei-Lenovo-ideapad-110-15ISK:~$ sudo update-alternatives --config python
[sudo] shanlei 的密码: 
有 2 个候选项可用于替换 python (提供 /usr/bin/python)。

  选择       路径            优先级  状态
------------------------------------------------------------
* 0            /usr/bin/python3   150       自动模式
  1            /usr/bin/python2   100       手动模式
  2            /usr/bin/python3   150       手动模式

要维持当前值[*]请按<回车键>,或者键入选择的编号:1
update-alternatives: 使用 /usr/bin/python2 来在手动模式中提供 /usr/bin/python (python)
shanlei@shanlei-Lenovo-ideapad-110-15ISK:~$ python --version
Python 2.7.15rc1
shanlei@shanlei-Lenovo-ideapad-110-15ISK:~$ 

選択したタイプを切り替える切り替え時その後、我々は、このコマンドのPythonのバージョンを使用することができます。

sudo update-alternatives --config python

おすすめ

転載: www.cnblogs.com/jlmgary/p/12435804.html