There are several ways to install Python on Linux, that is, if you need to install it at all!
Most Linux distributions include Python. Many will include both Python 2 and Python 3.
If you enter python --version
on the command line, you’ll see the version number. It’s probably version 2.7:
$ python --version Python 2.7.16
You don’t want Python 2, but some OS’es still ship with it, unfortunately.
Now try python3 --version
. If you get a “command not found,” you need to install Python 3. If your output looks similar to this, you’re in luck:
$ python3 --version Python 3.8.5
Depending on the distribution of Linux you are running, you can install python with the default package manager: Yum, APT, etcetera. You’ll need to find out for your specific Linux distribution which package manager is used and how to use it.
If you’re on Ubuntu, Linux Mint, or Debian, you can install python using apt:
$ apt install python3
Another interesting option for Linux is using Homebrew. It’s a top-rated package manager for Macs, but it also supports Linux.
The major advantages of using Homebrew:
I find myself using Homebrew more and more while working under Linux — give it a try, especially if you want to enjoy the latest and greatest Python version!