温馨提示×

ubuntu哪些python版本可用

小樊
43
2026-09-16 15:02:06
栏目: 编程语言

Ubuntu 上,可用的 Python 版本主要取决于:Ubuntu 系统版本 以及你是否通过官方源 / PPA / 编译安装。

下面按常见情况给你梳理一下。


一、Ubuntu 官方仓库中常见的 Python 版本

1. Ubuntu 20.04 LTS(Focal)

默认 Python 3:3.8 可安装:

  • python3.6(部分源)
  • python3.7
  • python3.8(默认)
  • python3.9(通过 PPA)

2. Ubuntu 22.04 LTS(Jammy)

默认 Python 3:3.10 可安装:

  • python3.8
  • python3.9
  • python3.10(默认)
  • python3.11(PPA)

3. Ubuntu 24.04 LTS(Noble)

默认 Python 3:3.12 可安装:

  • python3.10
  • python3.11
  • python3.12(默认)
  • python3.13(PPA / 后续支持)

二、查看你当前系统可用的 Python 版本

ls /usr/bin/python3*

或:

apt list --installed | grep python3

三、安装其他 Python 版本(推荐方式)

方法 1:使用 deadsnakes PPA(最常用)

sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update

# 示例:安装 Python 3.11
sudo apt install python3.11

方法 2:使用 pyenv(多版本管理,推荐开发用)

curl https://pyenv.run | bash
pyenv install 3.9.18
pyenv install 3.11.6
pyenv global 3.11.6

四、Python 2 的情况(重要)

  • Ubuntu 20.04 之后默认不再安装 Python 2
  • Python 2 已停止维护(EOL)
  • 不推荐新项目使用

五、快速建议

场景 推荐版本
新项目 Python 3.10+
兼容旧库 3.8 / 3.9
学习 3.10 / 3.11
生产服务器 LTS 对应默认版本

如果你愿意,可以告诉我:

  • 你的 Ubuntu 版本
  • 开发 / 服务器 / 学习

我可以给你更精确的安装方案。

0