3

On a RHEL 8.3 system I have two python3 versions installed and they show up as the version when I list alterantives' versions:

$ 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.

How can I use the alternatives command to choose the already listed python3.9 as the used version? (I.e. system-wide I want to execute python3.9 when I type on the command line python3).

Note: I understand I can add a new version with alternatives --install (and then make it the best one with a high priority), but how can I choose an already listed version as the best (and used) one?

1
  • Please note that several system libraries are linked to python3.6. That's the same as /usr/libexec/platform-python. If you want to script system administration on RHEL8, then rather stick to 3.6 Commented Jan 25 at 10:09

2 Answers 2

5
alternatives --config python3

will display a list of installed python3 releases and you can choose which to use. Note that this will lock you to that selection. Installing a new higher release will not automatically be used by the system.

alternatives --auto python3

will reset the --config so the system will use what it considers the best release automatically when new releases are installed.

0
1

Just a note that if you want to set python3 version in batch script without interactive promt, you may use command

alternatives --set python3 /usr/bin/python3.9

And optionally

alternatives --set python /usr/bin/python3.9

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .