Install Python: Detailed Instructions for Window, Mac, and Linux

This chapter teaches you how to install Python on MacOS, Windows, and Linux. We’ll look at multiple installation methods per platform and discuss which one I think is the best option.

Most of the time, it is not advisable to use the official installer from the python.org website. Instead, it is better to opt for the version packaged by your operating system. The advantage of a version supplied by the operating system is that you will get automatic updates.

Install

Python on Windows

There are three methods you can choose from on Windows

. Using Microsoft Store Microsoft hosts a community version of Python 3 in the Microsoft Store

. This is the recommended way to install Python on Windows because it handles updates automatically and can also be easily uninstalled.

To use this method:

  • Open the Microsoft Store and search for
  • Python

  • Choose the latest version and install it

With

the official installer

You can also download a Python installer from the official Python downloads website. This method doesn’t provide you with automatic updates, and I recommend it only if you don’t have access to the Microsoft store. When using this installer, make

sure to check the checkbox that says ‘Add Python to PATH’:

Install PythonMake sure to
check the ‘Add Python to PATH’ checkbox

inside

WSL

If you’re familiar with the Windows subsystem for Linux, you might want to consider that option as well. It’s what I use myself, and I really love it. It offers me the advantages offered by Windows (mainly great hardware support) while still enjoying Linux, which is, in my opinion, the best platform for Python development.

To install to WSL

, you must first install WSL. Opt for WSL2 if you can. It’s much better. After that, follow the Linux installation instructions below!

Installation in

MacOS

In most versions of MacOS prior to Catalina, a Python distribution is already included. Unfortunately, it is almost certainly an old version, Python 2.7. Fortunately, there are two ways to install Python 3 on a Mac easily.

Homebrew

First of all, I recommend looking into Homebrew. It allows you to install almost anything easily. The added benefits:

  • Homebrew packages are usually very up-to-date
  • .

  • It’s also easy to upgrade to newer versions later.

However, you should be comfortable using a command line shell to use Homebrew. If that’s completely new to you, I recommend the following option for now: use the official installer.

If you choose to install Homebrew, installing Python on MacOS is as easy as

: $ brew install pythonCode language: Bash (bash)

Official

installer

Alternatively, you can download an installer from the Python download website. It is easy and works just like installing any other MacOS software program. The downside to this approach is that you won’t get automatic updates. As with Windows, you need to make sure that Python is added to your system’s PATH.

Install

Python on Linux

There are several ways to install Python on Linux, that’s if you need to install it!

Check what installs first

Most Linux distributions include Python. Many will include Python 2 and Python 3.

If you enter python -version on the command line, you will see the version number. It’s probably version

2.7: $ python -version Python 2.7.16Code language: Bash (bash)

Unfortunately, you don’t want Python 2, but some operating systems still ship with it

.

Now try python3 -version. If you get a “command not found”, you need to install Python 3. If your output looks like this, you’re in luck

: $python3 -version Python 3.8.5Code language: Bash (bash) Using

a

package manager Depending on the

Linux distribution you’re running, you can install Python with the default package manager: Yum, APT, and so on. You will need to determine 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-python3Code language: Bash (bash)

This also installs a package called python-is-python3, which makes the python command 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 to use Homebrew. That’s right, the package manager for Mac also works on Linux.

The main advantages of using Homebrew:

You’ll get the latest version of

  • Python, rather than the version your OS shipped with.
  • You don’t need root access to your system. All 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

! Python

in

your browser

If you don’t feel like installing Python, or can’t install it for any reason, I’ll also offer you an alternative: you can use Python directly from your browser; No need to install it!

More information

This article is part of a free Python tutorial. You can navigate through the tutorial with the navigation buttons at the top and bottom of the article or use the navigation menu. Want to know more? All Python installation methods also install a tool called pip. Pip is used to install Python packages that do not come with the default Python installation. Later in this tutorial, we’ll look extensively at how to use Pip and some alternatives that have even more to offer, such as Python Poetry and Pipenv.