Monday, May 13, 2024
132
rated 0 times [  132] [ 0]  / answers: 1 / hits: 568783  / 2 Years ago, wed, march 30, 2022, 8:12:04

If I open Terminal and type in python, I see the version is 2.7.4. How do I get python 3.4? And do I need IDLE if I have sublime text?


More From » software-installation

 Answers
2

python 3.4 is installed on the stable release of Ubuntu 14.04. You need to use python3 to use python 3.4. For example, to execute a script file.py, use:



python3 file.py


This will use python 3.4 to interpret your program or you can use the shebang to make it executable. The first line of your program should be:



#!/usr/bin/env python3


and then use chmod +x file.py to assign executable permissions and then run your python script as ./file.py which would use python3 to execute.



If you want python3 to be used when you type python on the terminal, you can use an alias. To add a new alias, open your ~/.bash_aliases file using gedit ~/.bash_aliases and type the following:



alias python=python3


and then save and exit and type



source ~/.bash_aliases


and then you can type



python file.py


to use python3 as your default python interpreter.



No, you don't need IDLE just to use python3 to interpret your programs.


[#25959] Friday, April 1, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
fertion

Total Points: 436
Total Questions: 121
Total Answers: 156

Location: England
Member since Sun, May 21, 2023
1 Year ago
fertion questions
Thu, Mar 9, 23, 06:46, 1 Year ago
Thu, Jun 17, 21, 01:06, 3 Years ago
Mon, Jun 13, 22, 07:30, 2 Years ago
Fri, Mar 10, 23, 12:13, 1 Year ago
;