LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-21-2023, 09:13 PM   #1
Calab
Member
 
Registered: Oct 2003
Location: Calgary, AB, Canada
Distribution: CentOS, Ubuntu
Posts: 56

Rep: Reputation: 2
Question Set Python 3.11 as the default Python3 on RHEL


I have a machine running RHEL 7.9. On this system I have python 2.7.5, 3.7.11 and 3.11.2. All seem to be working as they should.

The system default for python3 is 3.7. How can I have the system use python 3.11 as the default python3?

I have added python 3.7 and 3.11 to the alternatives, and selected 3.11 as the default, but I still get 3.7 when I run python3:

$ update-alternatives --list | grep py
python3 manual /usr/bin/python3.11
$ python3 -V
Python 3.7.11
$ update-alternatives --config python3

There are 2 programs which provide 'python3'.

Selection Command
-----------------------------------------------
1 /usr/bin/python3.7
*+ 2 /usr/bin/python3.11

Enter to keep the current selection[+], or type selection number:
 
Old 04-22-2023, 04:01 AM   #2
lvm_
Member
 
Registered: Jul 2020
Posts: 965

Rep: Reputation: 342Reputation: 342Reputation: 342Reputation: 342
/usr/bin/python3 is a link to a versioned binary, point it to python3.11
 
Old 04-22-2023, 04:32 AM   #3
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,982

Rep: Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337
do not change the default python. That will kill your system.
 
Old 04-22-2023, 10:12 AM   #4
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,146
Blog Entries: 6

Rep: Reputation: 1834Reputation: 1834Reputation: 1834Reputation: 1834Reputation: 1834Reputation: 1834Reputation: 1834Reputation: 1834Reputation: 1834Reputation: 1834Reputation: 1834
You can also call the version on the shebang.
Code:
#!/usr/bin/python3.11

import random

mylist = list("abcdefg")
random.shuffle(mylist)
print(mylist)
 
Old 04-25-2023, 08:19 AM   #5
Calab
Member
 
Registered: Oct 2003
Location: Calgary, AB, Canada
Distribution: CentOS, Ubuntu
Posts: 56

Original Poster
Rep: Reputation: 2
Exclamation

Quote:
Originally Posted by pan64 View Post
do not change the default python. That will kill your system.
Thanks! I won't be changing the default.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
python3 -V returns Python 2.7.12, can't get python3 to work. gene_ Ubuntu 15 03-18-2019 10:39 AM
[SOLVED] making python3.6.4 default python3 Astral Axiom Linux - Newbie 17 04-14-2018 10:55 AM
[SOLVED] how to start python3.6 interpreter just by typing python in terminal not python3.6 bmohanraj91 Linux - Newbie 4 05-10-2017 07:51 AM
After upgrade python3.4 to python3.5.1 , not able to install packages "request" though pip3 YOGESHAS87 Linux - Software 1 08-03-2016 10:38 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration