文章目录
- sudo apt update sudo apt install software-properties-common sudo add-apt-repository ppa:deadsnakes/ppa sudo apt update sudo apt install python3.11 # 或者 python3.12 如果你更倾向于最新版本 sudo update-alternatives –install /usr/bin/python3 python3 /usr/bin/python3.10 1 sudo update-alternatives –install /usr/bin/python3 python3 /usr/bin/python3.11 2
- python3 –version
- sudo update-alternatives –config python3
- 你会看到一个列表,类似于这样: There are 2 choices for the alternative python3 (providing /usr/bin/python3). Selection Path Priority Status ———————————————————— * 0 /usr/bin/python3.11 2 auto mode 1 /usr/bin/python3.10 1 manual mode 2 /usr/bin/python3.11 2 manual mode Press <enter> to keep the current choice[*], or type selection number: Path 列显示了可用的 Python 可执行文件的路径。 Priority 列显示了你之前设置的优先级(数值越大,优先级越高)。 * 表示当前被选中的默认版本。 auto mode 表示系统自动选择最高优先级的版本。 manual mode 表示你手动指定了某个版本。 选择你想要的版本: 根据上述列表,找到你原来的 Python 版本(例如 python3.10)对应的 Selection 数字。 在示例中,python3.10 的选择号是 1。 输入对应的数字(例如 1),然后按 Enter 键。
目录
- 升级系统Python版本 (适用于全局修改)
- 对于Ubuntu/Debian系统
- 安装后,验证Python版本
- 查看当前python3的可选版本
- 运行这个命令后
- 总结
如果你希望将系统默认的 Python 版本升级到 3.11 或更高,以便所有项目都能使用新版本,可以采取此方案。具体步骤取决于你的操作系统。
sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.11 # 或者 python3.12 如果你更倾向于最新版本
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 2
python3 --version
sudo update-alternatives --config python3
你会看到一个列表,类似于这样:
There are 2 choices for the alternative python3 (providing /usr/bin/python3). Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/bin/python3.11 2 auto mode 1 /usr/bin/python3.10 1 manual mode 2 /usr/bin/python3.11 2 manual mode Press <enter> to keep the current choice[*], or type selection number:
- Path 列显示了可用的 Python 可执行文件的路径。
- Priority 列显示了你之前设置的优先级(数值越大,优先级越高)。
- * 表示当前被选中的默认版本。
- auto mode 表示系统自动选择最高优先级的版本。
- manual mode 表示你手动指定了某个版本。
选择你想要的版本:
- 根据上述列表,找到你原来的 Python 版本(例如 python3.10)对应的 Selection 数字。
- 在示例中,python3.10 的选择号是 1。
- 输入对应的数字(例如 1),然后按 Enter 键。
以上为个人经验,希望能给大家一个参考,也希望大家多多支持风君子博客。
您可能感兴趣的文章:
- 更改linux系统的默认Python版本方式
- 在Linux系统中升级python版本的三种方法
- Linux下把Python3设为默认Python版本的三种方法
- Linux删除系统自带版本Python过程详解
- linux安装python修改默认python版本方法
- Linux下多个Python版本安装教程