Red Hat Training
A Red Hat training course is available for RHEL 8
第 39 章 配置未指定版本的 Python
系统管理员可以使用 alternatives
命令配置位于 /usr/bin/python
的被指定版本的 python
命令。请注意,必须先安装所需的软件包 python3、
python38
、python39
或 python2
,然后才能将未指定版本的命令配置为对应的版本。
重要
/usr/bin/python
执行文件由 alternatives
系统控制。更新时可能会覆盖任何手动更改。
其他 Python 相关命令(如 pip3)
没有可配置的未指定版本的变体。
39.1. 直接配置未指定版本的 python 命令
您可以将未指定版本的 python
命令直接配置为所选 Python 版本。
先决条件
- 确定安装了所需的 Python 版本。
流程
要将未指定版本的
python
命令配置为 Python 3.6,请使用:# alternatives --set python /usr/bin/python3
要将未指定版本的
python
命令配置为 Python 3.8,请使用:# alternatives --set python /usr/bin/python3.8
要将未指定版本的
python
命令配置为 Python 3.9,请使用:# alternatives --set python /usr/bin/python3.9
要将未指定版本的
python
命令配置为 Python 2,请使用:# alternatives --set python /usr/bin/python2