如何在Linux 中安装 Python 3.10

Crq
Crq
管理员
1916
文章
0
粉丝
Linux教程评论6字数 611阅读2分2秒阅读模式
摘要计划为工作安装 Python 3.10?以下是在 Ubuntu 和相关发行版中安装 Python 3.10 的方法。

如何在Linux 中安装 Python 3.10

Python 3.10 于 2021 年 10 月 25 日发布,具有附加功能和更新。此版本带来了更好的错误消息处理、新的模式匹配功能、类型别名(TypeAlias)、用户定义的类型保护等。你可以在 docs.python.org 阅读发布重点。

在编写本指南时,大多数当前发行版都采用 Python 3.10。例如,Ubuntu 22.04 LTS 和 Fedora 36 默认都有 Python 3.10。

也就是说,如果你现在在任何不支持的版本中需要 Python 3.10,你可以使用 github.com 在 Ubuntu 中安装最新的 Python 3.10。下面是方法。

如何在 Ubuntu 上安装 Python 3.10

此 PPA 可用于 Ubuntu 21.10、Ubuntu 21.04、Ubuntu 20.04 LTS、Ubuntu 18.04 LTS 和 Linux Mint 20.x、Elementary OS 6 和其他相关的基于 Ubuntu 的发行版。这些发行版大多数默认情况下不支持 3.10。

打开终端并添加以下 PPA:

sudo add-apt-repository ppa:deadsnakes/ppa

使用以下命令刷新缓存:

sudo apt update

并使用以下命令安装 Python 3.10:

sudo apt install python3.10
设置 Python 版本

将 Python 3.10 设置为默认值需要一些额外的步骤。如下。

警告:你的 Ubuntu 系统中的许多应用程序依赖于 Python 3.9 的库存版本。因此,请确保你的工作应用(例如 GIMP、GNOME 终端等)与 Python 3.10 兼容。所以,要小心。

快速提示: 如果要检查已安装的系统包中的哪些依赖于特定版本,请使用apt-cache命令的rdepends开关。在下面的示例中,我检查哪些已安装的包依赖于 Python 3.8。

apt-cache rdepends python3.8
[~]$ apt-cache rdepends python3.8
python3.8
Reverse Depends:
python3.8-dbg
virtualbox
python3.8-venv
python3.8-full
libpython3.8-testsuite
libglib2.0-tests
idle-python3.8
idle-python3.8
python3.8-minimal
python3.8-doc
python3.8-dev
python3.8-dbg
python3-uno
gedit
virtualbox
stimfit
python3.8-venv
python3-stfio
python3-escript-mpi
python3-escript
python3-csound
pitivi
obs-studio
liferea
libpython3.8-testsuite
libglib2.0-tests
kitty
kdevelop-python
idle-python3.8
idle-python3.8
rhythmbox-plugins
python3.8-minimal
python3.8-doc
python3.8-dev
python3
python3-uno
python3-all
cluster-glue
gedit
[~]$
使用 Python 3.10 作为默认 Python3

首先,使用终端中的以下命令检查当前默认版本。

python3 --version

使用update-alternatives创建指向python3的符号链接。

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 2

并通过以下命令选择使用哪一个作为python3:

sudo update-alternatives --config python3

这就是所有步骤。现在,你可以开始在当前的 Ubuntu 版本中使用最新的 Python 进行工作/学习。你可以使用上述命令切换到库存版本并在任何时间更改版本号。


via: https://linux.cn/lctt/geekpi
作者: 译者:校对:
本文由 LCTT 原创翻译,Linux中国 荣誉推出

weinxin
我的微信
微信号已复制
我的微信
这是我的微信扫一扫
 
Crq
  • 本文由 Crq 发表于2025年3月19日 15:40:23
  • 转载请注明:https://www.cncrq.com/13512.html
Nginx源码安装及调优配置 Linux教程

Nginx源码安装及调优配置

由于Nginx本身的一些优点,轻量,开源,易用,越来越多的公司使用nginx作为自己公司的web应用服务器,本文详细介绍nginx源码安装的同时并对nginx进行优化配置。
凭什么说密钥比密码更好 Linux教程

凭什么说密钥比密码更好

也许人们已经有过这种感觉,或者已经想象过了。当意识到刚刚把登录证书输入了一个假网站的那一刻,你会感到恐慌。也许你马上就意识到了。又或者你在第二天返回后无法登录时才意识到这一点。也许...
匿名

发表评论

匿名网友
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:
确定

拖动滑块以完成验证