Python is installed to all of our computers because it is useful framework for a variety of things .
To use the python interface from terminal just type python .
to check you python version just type python --version
to run a python script you need to type in the form :
./python_script_name.py
but very importantly it has to be executable first
chmod +x python_script_name.py
I hope it helps !
Answer from billybadass on askubuntu.comPython is installed to all of our computers because it is useful framework for a variety of things .
To use the python interface from terminal just type python .
to check you python version just type python --version
to run a python script you need to type in the form :
./python_script_name.py
but very importantly it has to be executable first
chmod +x python_script_name.py
I hope it helps !
just type :
sudo apt-get install python
It will show you whether you have newest version of python or you should upgrade
Install python 3.11.9 on ubuntu
How do I install python?
How to download and use python on ubuntu? - Stack Overflow
How can I install Python 3.9 on a Linux Ubuntu terminal? - Stack Overflow
Videos
Hey Reddit. I'm super new to ubuntu. (like 3 days ago I got my first machine running it.) and need some quick help. I want to install python so I can run code on the machine and I have no idea how to do that. I'm guessing it'll be something like "sudo install python3.9". thanks for the help!
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:

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
>>>
If you are on Ubuntu 19.10 (Eoan Ermine) (or any other version unsupported by the deadsnakes PPA), you will not be able to install using the deadsnakes PPA.
What you can do instead, is get the source from Python's official website, and install it manually, as described here.
To do so, first, install the dependencies required to build the Python package.
sudo apt install build-essential zlib1g-dev \
libncurses5-dev libgdbm-dev libnss3-dev \
libssl-dev libreadline-dev libffi-dev curl software-properties-common
Then download the tarball and extract it:
wget https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tar.xz
tar -xf Python-3.9.0.tar.xz
Then cd to the extracted directory:
cd Python-3.9.0
Now configure the script:
./configure
Now, to install Python 3.9 alongside your current Python installation (if any), use:
sudo make altinstall
Lastly, you can verify your installation using
python3.9 --version
How to make python3.X default of Python 3? (Optional)
rm /usr/bin/python3
ln -s /usr/bin/python3.5 /usr/bin/python3
- create an alias in ~/.bash_aliases, ~/.zshrc, etc.
alias python3='/usr/bin/python3.9'
or
alias python3='/usr/local/bin/python3.9'
You are getting that error because you first need to update the package list and the prerequisites.
sudo apt update
sudo apt install software-properties-common
Then, add the repository ppa:deadsnakes/ppa to your sources list (where you will download Python from)
sudo add-apt-repository ppa:deadsnakes/ppa
Make sure to press Enter when prompted. Then update available the packages:
sudo apt update
Lastly, install the version of your choice:
sudo apt install python3.9
Make sure to read this:
Disclaimer: there's no guarantee of timely updates in case of security problems or other issues. If you want to use them in a security-or-otherwise-critical environment (say, on a production server), you do so at your own risk.
PPA Deadsnake