Getting started
Basic concepts: taking our first steps
Using an IDE
Objects and classes
Loops, ranges, and iterators
Working with files
Exception handling
Python data types
Course project: building a TODO application
And now what?

Installing Python on Linux

There are several ways to install Python on Linux if you need to install it at all!

Check what’s installed first

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

Using a package manager

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 which package manager is used for your specific Linux distribution and how to use it.

If you’re on Ubuntu, Linux Mint, or Debian, you can install using apt:

$ apt install python3 python-is-python3

This also installs a package called python-is-python3, which makes the command python point to python3. Trust me when I say it will save you a lot of headaches later on.

Homebrew

Another interesting option for Linux is using Homebrew. That’s right, the package manager for Macs also works on Linux.

The major advantages of using Homebrew:

  • You’ll get the latest version of Python, instead of the version your OS shipped with
  • You don’t need root access to your system. All the software installed with Homebrew is installed in your home directory

I find myself using Homebrew more and more while working under Linux — give it a try!