在 RHEL8 上,如何使用“alternatives”选择已列出的版本作为使用的版本

hal*_*leo 3 rhel alternatives python3

在 RHEL 8.3 系统上,我安装了两个 python3 版本,当我列出替代版本时,它们显示为版本:

$ alternatives --display python3

/usr/bin/python3.6 - priority 1000000
 slave easy_install-3: /usr/bin/easy_install-3.6
 slave pip-3: /usr/bin/pip-3.6
 slave pip3: /usr/bin/pip3.6
 slave pydoc-3: /usr/bin/pydoc3.6
 slave pydoc3: /usr/bin/pydoc3.6
 slave pyvenv-3: /usr/bin/pyvenv-3.6
 slave python3-man: /usr/share/man/man1/python3.6.1.gz
/usr/bin/python3.9 - priority 3900
 slave easy_install-3: /usr/bin/easy_install-3.9
 slave pip-3: /usr/bin/pip-3.9
 slave pip3: /usr/bin/pip3.9
 slave pydoc-3: /usr/bin/pydoc3.9
 slave pydoc3: /usr/bin/pydoc3.9
 slave pyvenv-3: (null)
 slave python3-man: /usr/share/man/man1/python3.9.1.gz
Current `best' version is /usr/bin/python3.6.
Run Code Online (Sandbox Code Playgroud)

如何使用该alternatives命令选择已列出的python3.9已使用版本?python3.9(即,当我在命令行上键入时,我想在系统范围内执行python3)。

注意:我知道我可以添加一个版本alternatives --install(然后使其成为具有高优先级的最佳版本),但如何选择列出的版本作为最佳(和使用的)版本?

小智 5

alternatives --config python3
Run Code Online (Sandbox Code Playgroud)

将显示已安装版本的列表python3,您可以选择要使用的版本。请注意,这会将您锁定到该选择。安装新的更高版本不会被系统自动使用。

alternatives --auto python3
Run Code Online (Sandbox Code Playgroud)

将重置,--config以便系统在安装新版本时自动使用它认为最好的版本。