How to download and use python on ubuntu? [closed]
Solution 1:
To begin, open a console window.
To install Python 3:
sudo apt-get update
sudo apt-get -y install python3.3
To install IDLE:
sudo apt-get install idle3
Keep in mind that you can also open a terminal window and simply type python
to be thrown into a python console. Python 3 may need to be forced with python3
if apt as decided not to overwrite your system's default 2.7.5 install.
There are also other environments similar to IDLE that can be a lot nicer to use. One such example is a plugin for the Sublime Text
text editor called SublimeREPL
(A REPL is a Read Evaluate Print Loop - essentially the interactive python prompt). These REPLs are available for many interpreted languages and can be very handy to have close by when you're writing code.
Here's what it looks like on my OSX install:
Solution 2:
Upgrading Python (or any package)
$ sudo apt-get update
$ sudo apt-get upgrade python
Using Python
$ python
Python 2.7.4 (default, Sep 26 2013, 03:20:26)
[GCC 4.7.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print "bacon"
bacon
>>>
Solution 3:
If you want python 3, you need to run:
sudo apt-get -y install python3.3
If you have an older Ubuntu distro you can download the gz
and compile it. This shows an example on how to do it: https://askubuntu.com/questions/244544/how-to-install-python-3-3
Solution 4:
Now(2020) the latest version for download the python is 3.8 so you install it using
sudo apt install python3.8
by Default python install in ubuntu
so you check version by typing in terminal(Ctrl+Alt+T) python3 -V
if show older version then configure it
type in terminal
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8.1
If one more version available then config it in terminal using:
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6(any version that already exist in system)
If there are many python versions in your system then you can set any by default to latest version by using this command in terminal:
sudo update-alternatives --config python3
When you hit enter then show you some messages like
There are 2 choices for the alternative python3 (providing /usr/bin/python3).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/bin/python3.6 2 auto mode
1 /usr/bin/python3.6 2 manual mode
* 2 /usr/bin/python3.8 1 manual mode
Press <enter> to keep the current choice[*], or type selection number:
According to your configuration it will display versions of python. It depends on your requirement any time you change it like so
if type selection 2
then the python latest version set by default
python3 -V
Python 3.8.0