Installing the Python interpreter and working with IDLE
This article provides a step-by-step guide on how to install the Python interpreter on different platforms.
Last updated
This article provides a step-by-step guide on how to install the Python interpreter on different platforms.
Last updated
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 , 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!
There are three installation methods on Windows:
The Microsoft Store
The full installer
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.
To check if you already have Python on your Windows machine, first open a command-line
application, such as PowerShell
.
Tip: Here’s how you open PowerShell:
Press the
Win
key.Type
PowerShell
.Press Enter.
Alternatively, you can right-click the Start button and select Windows PowerShell or Windows PowerShell (Admin).
With the command line open, type in the following command and press Enter
:
Using the --version
switch will show you the version that’s installed. Alternatively, you can use the -V
switch:
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.
Note: If you don’t have a version of Python on your system, then both of the above commands will launch the Microsoft Store and redirect you to the Python application page. You’ll see how to complete the installation from the Microsoft Store in the next section.
If you’re interested in where the installation is located, then you can use the where.exe
command in cmd.exe
or PowerShell:
Note: that the
where.exe
command will work only if Python has been installed for your user account.
As mentioned earlier, there are three ways to install the official Python distribution on Windows:
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.
In this section, we’ll focus on only the first two options, which are the most popular installation methods in a Windows environment.
The two official Python installers for Windows aren’t identical. The Microsoft Store package has some important limitations.
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:
Select Python 3.8
, or the highest version number you see available in the app, to open the installation page.
Warning: Make sure that the Python application you’ve selected is created by the Python Software Foundation.
The official Microsoft Store package will always be free, so if the application costs money, then it’s the wrong application.
Alternatively, you can open PowerShell and type the following command:
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:
Click Get
.
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.
Click Install
on my devices and select the devices on which you’d like to complete the installation.
Click Install
Now and then OK
to start the installation.
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
!
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:
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
.
Scroll to the bottom and select either Windows x86-64
executable installer for 64-bit or Windows x86
executable installer for 32-bit
.
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.
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:
There are four things to notice about this dialog box:
The default install path is in the AppData/
directory of the current Windows user.
The Customize installation button can be used to customize the installation location and which additional features get installed, including pip
and IDLE.
The full installer gives you total control over the installation process.
Warning: If you don’t know what
PATH
is, then it’s highly recommended that you do not install with the full installer. Use the Microsoft Store package instead.
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!
There are two installation methods on macOS:
The official installer
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.
To check which Python version you have on your Mac, first open a command-line application, such as Terminal.
Tip: Here’s how you open Terminal:
Press the
Cmd
+Space
keys.Type
Terminal
.Press Enter.
Alternatively, you can open Finder and navigate to Applications → Utilities → Terminal.
With the command line open, type in the following commands:
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.6.10 were already set up on your computer, then the python3
command would display that version number:
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.
There are two ways to install the official Python distribution on macOS:
The official installer: This method involves downloading the official installer from the Python.org website and running it on your machine.
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.
Installing Python from the official installer is the most reliable installation method on macOS. It includes all the system dependencies needed for developing applications with Python.
You can install from the official installer in two steps.
Step 1: Download the Official Installer
Follow these steps to download the full installer:
Under the “Python Releases for Mac OS X” 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
.
Scroll to the bottom and click macOS
64-bit
installer to start the download.
When the installer is finished downloading, move on to the next step.
Step 2: Run the Installer
Run the installer by double-clicking the downloaded file. You should see the following window:
Follow these steps to complete the installation:
Press Continue
a few times until you’re asked to agree to the software license agreement. Then click Agree
.
You’ll be shown a window that tells you the install destination and how much space it will take. You most likely don’t want to change the default location, so go ahead and click Install
to start the installation.
When the installer is finished copying files, double-click the Install
Certificates command in the finder window to make sure your SSL root certificates are updated.
Congratulations—you now have the latest version of Python 3 on your macOS computer!
For users who need to install from the command line, especially those who won’t be using Python to develop graphical user interfaces with the Tkinter module, the Homebrew package manager is a good option. You can install from the Homebrew package manager in two steps.
Step 1: Install Homebrew
If you already have Homebrew installed, then you can skip this step. If you don’t have Homebrew installed, then use the following procedure to install Homebrew:
You should see a command for installing Homebrew near the top of the page under the tile “Install Homebrew.” This command will be something like the following:
Highlight the command with your cursor and press Cmd
+C
to copy it to your clipboard.
Open a terminal window and paste the command, then press Enter. This will begin the Homebrew installation.
Enter your macOS user password when prompted.
Depending on your Internet connection, it may take a few minutes to download all of Homebrew’s required files. Once the installation is complete, you’ll end up back at the shell prompt in your terminal window.
Note: If you’re doing this on a fresh install of macOS, you may get a pop-up alert asking you to install Apple’s command line developer tools. These tools are necessary for installation, so you can confirm the dialog box by clicking
Install
.After the developer tools are installed, you’ll need to press Enter to continue installation of Homebrew.
Now that Homebrew is installed, you’re ready to install Python.
Step 2: Install Python
Follow these steps to complete the installation with Homebrew:
Open a terminal application.
Type in the following command to upgrade Homebrew:
Installing with Homebrew is now as straightforward as running the command brew install python3
. This will download and set up the latest version of Python on your machine.
You can make sure everything went correctly by testing if you can access Python from the terminal:
Open a terminal.
Type pip3
and press Enter.
Congratulations—you now have Python on your macOS system!
There are two installation methods on Linux:
Using your operating system’s package manager
Building Python from source code
In this section, you’ll learn how to check which version of Python, if any, is on your Linux computer. You’ll also learn which of the two installation methods you should use.
Many Linux distributions come packaged with Python, but it probably won’t be the latest version and may even be Python 2 instead of Python 3. You should check the version to make sure.
To find out which version of Python you have, open a terminal window and try the following commands:
If you have Python on your machine, then one or more of these commands should respond with a version number.
For example, if you already had Python 3.6.10 on your computer, then the python3 --version
command would display that version number:
You’ll want to get the latest version of Python if your current version is in the Python 2.X series or is not the latest version of Python 3 available, which was 3.8.4 as of this writing.
Download the required version and follow the further instructions for the installation process.
Beginning the installation.
For almost every Linux system, the following command could be used to install Python directly:
To verify the installation enter the following commands in your Terminal.
Pythonista is surprisingly fun to use. It’s a great little tool when you’re stuck without a laptop and want to work on your Python skills on the go. It comes with the complete Python 3 standard library and even includes full documentation that you can browse offline.
Pydroid 3 features an interpreter that you can use for REPL sessions, and it also allows you to edit, save, and execute Python code.
If you want to try out the examples in this tutorial without setting up Python on your machine, then there are several websites that offer an online Python interpreter:
These cloud-based Python interpreters may not be able to execute some of the more complex examples in this tutorial, but they’re adequate for running most of the code and may be a nice way to get started. More information on using these sites is presented in the next tutorial in this series.
You can also use cmd.exe
or .
Full Installer: This approach involves downloading Python directly from the website. This is recommended for intermediate and advanced developers who need more control during the setup process.
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 .
Open a browser window and navigate to the Python.org .
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 .
The Install launcher for all users (recommended) checkbox is checked default. This means every user on the machine will have access to the . You can uncheck this box to restrict Python to the current Windows user.
The Add Python 3.8
to PATH
checkbox is unchecked by default. There are that you might not want Python on PATH
, so make sure you understand the implications before you check this box.
Python 2 comes preinstalled on older versions of macOS. This is no longer the case for current versions of macOS, .
The Homebrew package manager: This method involves downloading and installing if you don’t already have it installed, and then typing a command into a terminal application.
Note: You can also complete the installation on macOS using alternative distributions, such as , but this tutorial covers only official distributions.
Anaconda is a popular platform for doing scientific computing and data science with Python. To learn how to install Anaconda on macOS, check out the from the official Anaconda documentation.
Open a browser window and navigate to the Python.org .
Open a browser and navigate to .
You should see the help text from . If you get an error message running pip3
, then go through the install steps again to make sure you have a working installation.
Before starting with the installation process, you need to download it. For that all versions of Python for Linux are available on .
The for iOS is a full-fledged Python development environment that you can run on your iPhone or iPad. It features a Python editor, technical documentation, and an interpreter all rolled into a single app.
To set up Pythonista, you need to .
If you have an Android tablet or phone and want to practice Python on the go, there are several options available. The one that we found most reliably supports Python 3.8 is .
You can . There is a free version and also a paid Premium version that supports code prediction and code analysis.