Ubuntu22.0.4如何将python3.10换为python3.9
时间: 2023-09-22 18:08:35 浏览: 369
在 Ubuntu 22.04 中将 Python 3.10 更换为 Python 3.9,可以按照以下步骤进行操作:
1. 更新系统:
```shell
sudo apt update
sudo apt upgrade
```
2. 安装 Python 3.9:
```shell
sudo apt install python3.9
```
3. 检查 Python 3.9 是否成功安装:
```shell
python3.9 --version
```
4. 更新默认的 Python 版本:
```shell
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 1
```
5. 配置默认的 Python 版本:
```shell
sudo update-alternatives --config python3
```
运行上述命令后,会显示类似以下的选项:
```shell
There are 2 choices for the alternative python3 (providing /usr/bin/python3).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/bin/python3.10 10 auto mode
* 1 /usr/bin/python3.9 1 manual mode
2 /usr/bin/python3.10 10 manual mode
Press <enter> to keep the current choice[*], or type selection number:
```
输入对应 Python 3.9 的选择号码(这里是 1),然后按 Enter 键确认。
6. 确认 Python 版本已更改:
```shell
python3 --version
```
现在,你的系统中的默认 Python 版本应该已经更改为 Python 3.9。你可以使用 `python3` 命令来运行 Python 3.9 解释器。
阅读全文
相关推荐

















