1、首先查看系统中是否安装Python:
whereis python
如果已安装,将提示如下:
root@ubuntu:~# whereis python
python: /usr/bin/python /usr/bin/python2.7 /usr/bin/python3.5m /usr/bin/python3.5 /usr/bin/python2.7-config /usr/lib/python2.7 /usr/lib/python3.5 /etc/python /etc/python2.7/etc/python3.5 /usr/local/lib/python2.7 /usr/local/lib/python3.5 /usr/include/python2.7 /usr/share/python /usr/share/man/man1/python.1.gz
如果没安装,安装:sudo apt-get install python3
2、查看当前版本:python -V
3、切换版本:
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 100
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 150
如果要切换到python2,输入:
sudo update-alternatives --config python