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?
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
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:
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:
and then save and exit and type
and then you can type
to use python3 as your default python interpreter.
No, you don't need IDLE just to use python3 to interpret your programs.
I had the same issue with my ubuntu desktop. My python book told me to call python by just typing python in the terminal but it was only calling the previous python version 2.
- First check if you have python version 3 or not. Open command terminal, type
Do you see the acknowledgment that you do? done.
- If you don't; install using following command line.
sudo apt-get install python3
Hope this helps!
On Ubuntu 14.04 Python 3.4 is installed by default.
As recommended by PEP-394 you can use
python2 to run Python v2 (2.7) and
python3 to run Python v3 (3.4).
If needed for only one script, you can use an alias locally and temporarily.
When installing Letsencrypt, I got the following warning :
$ ./letsencrypt-auto --help InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning. InsecurePlatformWarning
The cause: Python 2.7.9 was needed, while 2.7.5 was installed. Python 3 works as well. I opened the script and inserted the following alias after the shebang:
Then the script worked. When it all finished this alias was removed. It only worked in this script. So starting
python from the terminal still got me version 2.7.5.
Ubuntu 18.04 LTS and above
Since Ubuntu 18.04 and beyond, you don't have to install Python 3, as it comes by default.
For Ubuntu 18.04 LTS and Debian Buster, we want to transition to Python 3.6 as the default (and probably only) Python 3 version.
Otherwise install by the following command:
sudo apt-get install python3
Then to locate multiple Python installations, run one of these commands:
whereis python which -a python python2 python3 locate python
or just type
python command and hit Tab twice.
To list installed Python packages, run:
dpkg -l | grep -w python.
To install a specific version, see: How to install specific Ubuntu packages, with exact version?