ubuntu改变python版本
时间: 2023-05-29 12:06:14 浏览: 97
Ubuntu默认安装了Python2和Python3,可以使用以下命令来切换不同版本的Python:
1. 查看当前系统中的Python版本
```
python -V
```
2. 切换到Python2
```
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 1
```
3. 切换到Python3
```
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 2
```
4. 切换回Python2
```
sudo update-alternatives --config python
```
执行上述命令后,会出现如下提示:
```
There are 2 choices for the alternative python (providing /usr/bin/python).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/bin/python3 2 auto mode
1 /usr/bin/python2 1 manual mode
2 /usr/bin/python3 2 manual mode
Press <enter> to keep the current choice[*], or type selection number:
```
输入数字1并按下回车键即可切换回Python2。
阅读全文