Python 3 Installation & Setup Guide

Python 3 Installation & Setup Guide

Watch Now This tutorial has a related video course created by the Real Python team. Watch it together with the written tutorial to deepen your understanding: Python Basics: Setting Up Python

Installing or updating Python on your computer is the first step to becoming a Python programmer. There are a multitude of installation methods: you can download official Python distributions from Python.org, install from a package manager, and even install specialized distributions for scientific computing, Internet of Things, and embedded systems.

This tutorial focuses on official distributions, as they’re generally the best option for getting started with learning to program in Python.

In this tutorial you’ll learn how to:

  • Check which version of Python, if any, is installed on your machine
  • Install or update Python on Windows, macOS, and Linux
  • Use Python on mobile devices like phones or tablets
  • Use Python on the Web with online interpreters

No matter what operating system you’re on, this tutorial has you covered. Find your operating system below and dive in!

How to Install Python on Windows

There are three installation methods on Windows:

  1. The Microsoft Store
  2. The full installer
  3. Windows Subsystem for Linux

In this section, you’ll learn how to check which version of Python, if any, is installed on your Windows computer. You’ll also learn which of the three installation methods you should use. For a more comprehensive guide, check out Your Python Coding Environment on Windows: Setup Guide.

How to Check Your Python Version on Windows

To check if you already have Python on your Windows machine, first open a command-line application, such as PowerShell.

You can also use cmd.exe or Windows Terminal.

With the command line open, type in the following command and press Enter:

Windows Command Prompt
C:\> python --version
Python 3.8.4

Using the --version switch will show you the version that’s installed. Alternatively, you can use the -V switch:

Windows Command Prompt
C:\> python -V
Python 3.8.4

In either case, if you see a version less than 3.8.4, which was the most recent version at the time of writing, then you’ll want to upgrade your installation.

If you’re interested in where the installation is located, then you can use the where.exe command in cmd.exe or PowerShell:

Windows Command Prompt
C:\> where.exe python
C:\Users\mertz\AppData\Local\Programs\Python\Python37-32\python.exe

Note that the where.exe command will work only if Python has been installed for your user account.

What Your Options Are

As mentioned earlier, there are three ways to install the official Python distribution on Windows:

  1. Microsoft Store package: The most straightforward installation method on Windows involves installing from the Microsoft Store app. This is recommended for beginner Python users looking for an easy-to-set-up interactive experience.

  2. Full Installer: This approach involves downloading Python directly from the Python.org website. This is recommended for intermediate and advanced developers who need more control during the setup process.

  3. Windows Subsystem for Linux (WSL): The WSL allows you to run a Linux environment directly in Windows. You can learn how to enable the WSL by reading the Windows Subsystem for Linux Installation Guide for Windows 10.

In this section, we’ll focus on only the first two options, which are the most popular installation methods in a Windows environment.

If you want to install in the WSL, then you can read the Linux section of this tutorial after you’ve installed the Linux distribution of your choice.

The two official Python installers for Windows aren’t identical. The Microsoft Store package has some important limitations.

Limitations of the Microsoft Store Package

The official Python documentation has this to say about the Microsoft Store package:

The Microsoft Store package is an easily installable Python interpreter that is intended mainly for interactive use, for example, by students. (Source)

The key takeaway here is that the Microsoft Store package is “intended mainly for interactive use.” That is, the Microsoft Store package is designed to be used by students and people learning to use Python for the first time.

In addition to targeting beginning Pythonistas, the Microsoft Store package has limitations that make it ill-suited for a professional development environment. In particular, it does not have full write access to shared locations such as TEMP or the registry.

Windows Installer Recommendations

If you’re new to Python and focused primarily on learning the language rather than building professional software, then you should install from the Microsoft Store package. This offers the shortest and easiest path to getting started with minimal hassle.

On the other hand, if you’re an experienced developer looking to develop professional software in a Windows environment, then the official Python.org installer is the right choice. Your installation won’t be limited by Microsoft Store policies, and you can control where the executable is installed and even add Python to PATH if necessary.

How to Install From the Microsoft Store

If you’re new to Python and looking to get started quickly, then the Microsoft Store package is the best way to get up and running without any fuss. You can install from the Microsoft Store in two steps.

Step 1: Open the Python App Page in the Microsoft Store

Open the Microsoft Store app and search for Python.

You’ll likely see multiple versions that you can choose to install:

The Microsoft Store search results for "Python"

Select Python 3.8, or the highest version number you see available in the app, to open the installation page.

Alternatively, you can open PowerShell and type the following command:

Windows Command Prompt
C:\> python

If you don’t already have a version of Python on your system, then when you press Enter, the Microsoft Store will automatically launch and take you to the latest version of Python in the store.

Step 2: Install the Python App

After you’ve selected the version to be installed, follow these steps to complete the installation:

  1. Click Get.

  2. Wait for the application to download. When it’s finished downloading, the Get button will be replaced with a button that says Install on my devices.

  3. Click Install on my devices and select the devices on which you’d like to complete the installation.

  4. Click Install Now and then OK to start the installation.

  5. If the installation was successful, then you’ll see the message “This product is installed” at the top of the Microsoft Store page.

Congratulations! You now have access to Python, including pip and IDLE!

How to Install From the Full Installer

For professional developers who need a full-featured Python development environment, installing from the full installer is the right choice. It offers more customization and control over the installation than installing from the Microsoft Store.

You can install from the full installer in two steps.

Step 1: Download the Full Installer

Follow these steps to download the full installer:

  1. Open a browser window and navigate to the Python.org Downloads page for Windows.

  2. Under the “Python Releases for Windows” heading, click the link for the Latest Python 3 Release - Python 3.x.x. As of this writing, the latest version was Python 3.8.4.

  3. Scroll to the bottom and select either Windows x86-64 executable installer for 64-bit or Windows x86 executable installer for 32-bit.

If you aren’t sure whether to select the 32-bit or the 64-bit installer, then you can expand the box below to help you decide.

For Windows, you can choose either the 32-bit or the 64-bit installer. Here’s the difference between the two:

  • If your system has a 32-bit processor, then you should choose the 32-bit installer. If you attempt to install the 64-bit version on a 32-bit processor, then you’ll get an error at the beginning and the install will fail.

  • On a 64-bit system, either installer will work for most purposes. The 32-bit version will generally use less memory, but the 64-bit version performs better for applications with intensive computation.

If you’re unsure which version to pick, go with the 64-bit version.

If you have a 64-bit system and would like to switch from 64-bit Python to 32-bit (or vice versa), then you can just uninstall Python and then reinstall it by downloading the other installer from Python.org.

When the installer is finished downloading, move on to the next step.

Step 2: Run the Installer

Once you’ve chosen and downloaded an installer, run it by double-clicking on the downloaded file. A dialog box like the one below will appear:

Windows installation dialog

There are four things to notice about this dialog box:

  1. The default install path is in the AppData/ directory of the current Windows user.

  2. The Customize installation button can be used to customize the installation location and which additional features get installed, including pip and IDLE.

  3. The Install launcher for all users (recommended) checkbox is checked default. This means every user on the machine will have access to the py.exe launcher. You can uncheck this box to restrict Python to the current Windows user.

  4. The Add Python 3.8 to PATH checkbox is unchecked by default. There are several reasons that you might not want Python on PATH, so make sure you understand the implications before you check this box.

The full installer gives you total control over the installation process.

Customize the installation to meet your needs using the options available on the dialog box. Then click Install Now. That’s all there is to it!

Congratulations—you now have the latest version of Python 3 on your Windows machine!

How to Install Python on macOS

Python 2 comes preinstalled on older versions of macOS. This is no longer the case for current versions of macOS, starting with macOS Catalina.

There are two installation methods on macOS:

  1. The official installer
  2. The Homebrew package manager

In this section, you’ll learn how to check which version of Python, if any, is installed on your macOS device. You’ll also learn which of the two installation methods you should use.

How to Check Your Python Version on a Mac

To check which Python version you have on your Mac, first open a command-line application, such as Terminal.

With the command line open, type in the following commands:

Shell
# Check the system Python version
$ python --version

# Check the Python 2 version
$ python2 --version

# Check the Python 3 version
$ python3 --version

If you have Python on your system, then one or more of these commands should respond with a version number.

For example, if Python 3.8.4 were already set up on your computer, then the python3 command would display that version number:

Shell
$ python3 --version
Python 3.8.4

Alternatively to --version, you can use the shorter -V switch:

Shell
$ python3 -V
Python 3.8.4

Either of these switches will give you the version number of the Python installation that the command is associated with.

You’ll want to get the latest version of Python if any of these conditions is true:

  • None of the above commands returns a version number.
  • The only version you see displayed is in the Python 2.X series.
  • You have a version of Python 3 that isn’t the latest available, which was version 3.8.4 as of this writing.

What Your Options Are

There are two ways to install the official Python distribution on macOS:

  1. The official installer: This method involves downloading the official installer from the Python.org website and running it on your machine.

  2. The Homebrew package manager: This method involves downloading and installing the Homebrew package manager if you don’t already have it installed, and then typing a command into a terminal application.

Both the official installer and the Homebrew package manager will work, but only the official installer is maintained by the Python Software Foundation.

The distributions installed by the official installer and the Homebrew package manager aren’t identical. Installing from Homebrew has some limitations.

Limitations of Installing From Homebrew

The Python distribution for macOS available on Homebrew doesn’t include the Tcl/Tk dependency required by the Tkinter module. Tkinter is the standard library module for developing graphical user interfaces in Python and is in fact an interface for the Tk GUI toolkit, which isn’t part of Python.

Homebrew doesn’t install the Tk GUI toolkit dependency. Instead, it relies on an existing version installed on your system. The system version of Tcl/Tk may be outdated or missing entirely and could prevent you from importing the Tkinter module.

macOS Installer Recommendations

The Homebrew package manager is a popular method for installing Python on macOS because it’s easy to manage from the command line and offers commands to upgrade Python without having to go to a website. Because Homebrew is a command-line utility, it can be automated with bash scripts.

However, the Python distribution offered by Homebrew isn’t controlled by the Python Software Foundation and could change at any time. The most reliable method on macOS is to use the official installer, especially if you plan on doing Python GUI programming with Tkinter.