Sentinel Now This tutorial has a related video course created past the Existent 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 developer. At that place are a multitude of installation methods: you can download official Python distributions from Python.org, install from a package managing director, and fifty-fifty install specialized distributions for scientific computing, Net of Things, and embedded systems.

This tutorial focuses on official distributions, as they're generally the best pick for getting started with learning to plan in Python.

In this tutorial yous'll learn how to:

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

No matter what operating system y'all're on, this tutorial has you covered. Find your operating system beneath 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 larn how to check which version of Python, if any, is installed on your Windows computer. Yous'll also learn which of the three installation methods you lot should use.

How to Check Your Python Version on Windows

To check if you already take 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 post-obit command and printing Enter :

                                                  C:\>                  python --version                  Python 3.eight.4                              

Using the --version switch volition show y'all the version that's installed. Alternatively, y'all tin can use the -V switch:

                                                  C:\>                  python -V                  Python 3.8.4                              

In either case, if you run into a version less than iii.8.4, which was the most recent version at the time of writing, then you'll desire to upgrade your installation.

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

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

Note that the where.exe control 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 piece of cake-to-set-up interactive experience.

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

  3. Windows Subsystem for Linux (WSL): The WSL allows you lot to run a Linux environment direct in Windows. Y'all tin can learn how to enable the WSL by reading the Windows Subsystem for Linux Installation Guide for Windows 10.

In this department, we'll focus on only the showtime 2 options, which are the most popular installation methods in a Windows environment.

If yous desire to install in the WSL, and then you tin 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 Shop Bundle

The official Python documentation has this to say virtually the Microsoft Store packet:

The Microsoft Store package is an easily installable Python interpreter that is intended mainly for interactive utilize, 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 bundle is designed to be used by students and people learning to use Python for the showtime time.

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

Windows Installer Recommendations

If you lot're new to Python and focused primarily on learning the language rather than edifice professional person software, and so you should install from the Microsoft Shop package. This offers the shortest and easiest path to getting started with minimal hassle.

On the other hand, if you lot're an experienced developer looking to develop professional software in a Windows environment, then the official Python.org installer is the right selection. Your installation won't exist limited by Microsoft Store policies, and you can command where the executable is installed and fifty-fifty add Python to PATH if necessary.

How to Install From the Microsoft Store

If yous're new to Python and looking to go started quickly, so the Microsoft Store bundle is the best way to get upward 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 Shop

Open the Microsoft Store app and search for Python.

Y'all'll likely come across multiple versions that you can choose to install:

The Microsoft Store search results for "Python"

Select Python three.8, or the highest version number you meet available in the app, to open the installation page.

Alternatively, you can open up PowerShell and blazon the following command:

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

Footstep 2: Install the Python App

Later y'all've selected the version to exist installed, follow these steps to complete the installation:

  1. Click Go.

  2. Wait for the application to download. When information technology's finished downloading, the Go button will exist replaced with a push 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 and so OK to commencement the installation.

  5. If the installation was successful, then you'll run into the message "This product is installed" at the acme of the Microsoft Shop page.

Congratulations! Y'all now have access to Python, including pip and IDLE!

How to Install From the Full Installer

For professional developers who demand a total-featured Python development surround, installing from the full installer is the right option. It offers more customization and command over the installation than installing from the Microsoft Shop.

Yous can install from the total installer in ii steps.

Pace i: 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.ten.x. As of this writing, the latest version was Python 3.8.four.

  3. Coil to the lesser 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-flake or the 64-chip installer, then yous tin expand the box below to help you lot make up one's mind.

For Windows, you can choose either the 32-scrap or the 64-scrap installer. Here'due south the deviation between the two:

  • If your arrangement has a 32-bit processor, then you lot should choose the 32-bit installer. If you lot try to install the 64-scrap version on a 32-bit processor, then you'll get an mistake at the beginning and the install will neglect.

  • On a 64-fleck organization, either installer will work for most purposes. The 32-bit version will generally utilize less retentivity, merely the 64-fleck version performs ameliorate for applications with intensive ciphering.

If you're unsure which version to pick, go with the 64-chip version.

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

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

Step ii: Run the Installer

Once y'all've chosen and downloaded an installer, run information technology past double-clicking on the downloaded file. A dialog box similar the one beneath will announced:

Windows installation dialog

There are 4 things to detect well-nigh this dialog box:

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

  2. The Customize installation push button tin 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 admission to the py.exe launcher. Yous can uncheck this box to restrict Python to the current Windows user.

  4. The Add Python 3.viii to PATH checkbox is unchecked past default. At that place are several reasons that y'all might not want Python on PATH, and then brand sure you lot understand the implications before you check this box.

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

Customize the installation to see your needs using the options bachelor on the dialog box. Then click Install Now. That's all there is to information technology!

Congratulations—you now accept the latest version of Python 3 on your Windows motorcar!

How to Install Python on macOS

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

There are 2 installation methods on macOS:

  1. The official installer
  2. The Homebrew parcel manager

In this department, you'll larn how to bank check which version of Python, if whatever, is installed on your macOS device. You'll too acquire which of the two installation methods you should utilize.

How to Cheque Your Python Version on a Mac

To check which Python version you have on your Mac, commencement open a control-line application, such as Concluding.

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

                                                  # Bank check the system Python version                  $ python --version                  # Check the Python two version                  $ python2 --version                  # Check the Python 3 version                  $ python3 --version                              

If you take Python on your system, and so 1 or more of these commands should respond with a version number.

For instance, if Python 3.6.10 were already set upward on your computer, and so the python3 command would display that version number:

                                                  $                  python3 --version                  Python 3.half dozen.x                              
You'll want to become the latest version of Python if any of these conditions is true:
  • None of the higher up commands returns a version number.
  • The only version you encounter displayed is in the Python 2.X serial.
  • Yous take a version of Python 3 that isn't the latest bachelor, 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 information technology on your machine.

  2. The Homebrew packet director: This method involves downloading and installing the Homebrew packet manager if you don't already have it installed, and then typing a control into a terminal awarding.

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

The distributions installed past the official installer and the Homebrew package director aren't identical. Installing from Homebrew has some limitations.

Limitations of Installing From Homebrew

The Python distribution for macOS bachelor 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 function of Python.

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

macOS Installer Recommendations

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

Withal, the Python distribution offered by Homebrew isn't controlled past the Python Software Foundation and could modify at whatsoever fourth dimension. The most reliable method on macOS is to utilize the official installer, especially if you lot plan on doing Python GUI programming with Tkinter.

How to Install From the Official Installer

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 ane: Download the Official Installer

Follow these steps to download the full installer:

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

  2. Under the "Python Releases for Mac OS X" heading, click the link for the Latest Python iii Release - Python three.10.x. As of this writing, the latest version was Python 3.8.iv.

  3. Roll to the lesser and click macOS 64-fleck installer to start the download.

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

Pace 2: Run the Installer

Run the installer past double-clicking the downloaded file. Y'all should see the following window:

The macOS installation window.

Follow these steps to consummate the installation:

  1. Printing Go along a few times until you're asked to agree to the software license agreement. Then click Agree.

  2. Y'all'll be shown a window that tells yous the install destination and how much infinite it volition take. You most probable don't want to change the default location, so go ahead and click Install to offset the installation.

  3. When the installer is finished copying files, click Shut to shut the installer window.

Congratulations—you now accept the latest version of Python 3 on your macOS estimator!

How to Install From Homebrew

For users who need to install from the command line, particularly those who won't exist using Python to develop graphical user interfaces with the Tkinter module, the Homebrew package manager is a good option. Yous can install from the Homebrew package manager in two steps.

Step 1: Install Homebrew

If you lot already have Homebrew installed, then you can skip this footstep. If you lot don't take Homebrew installed, and then employ the following procedure to install Homebrew:

  1. Open a browser and navigate to http://brew.sh/.

  2. You should come across a command for installing Homebrew near the top of the page nether the tile "Install Homebrew." This control will be something like the following:

                                                                        $                        /bin/fustigate -c                        "                        $(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/primary/install.sh)                        "                                          

    Highlight the command with your cursor and printing Cmd + C to copy it to your clipboard.

  3. Open a terminal window and paste the command, then press Enter . This volition begin the Homebrew installation.

  4. Enter your macOS user countersign when prompted.

Depending on your Cyberspace connection, it may accept a few minutes to download all of Homebrew's required files. Once the installation is complete, you lot'll end upwardly back at the shell prompt in your terminal window.

Now that Homebrew is installed, you're ready to install Python.

Pace two: Install Python

Follow these steps to complete the installation with Homebrew:

  1. Open a terminal awarding.

  2. Type in the following command to upgrade Homebrew:

                                                                        $                        brew update                        &&                        brew upgrade                                          

Installing with Homebrew is at present as straightforward every bit running the command brew install python3. This will download and set up upward the latest version of Python on your machine.

You tin can make sure everything went correctly by testing if y'all can admission Python from the last:

  1. Open a terminal.

  2. Blazon pip3 and printing Enter .

  3. Yous should encounter the aid text from Python's pip package manager. If you get an error bulletin running pip3, and then become through the install steps again to make sure you have a working installation.

Congratulations—you now have Python on your macOS arrangement!

How to Install Python on Linux

In that location are two installation methods on Linux:

  1. Using your operating organisation'due south parcel manager
  2. 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 lot'll also learn which of the ii installation methods you should use.

How to Check Your Python Version on Linux

Many Linux distributions come packaged with Python, only it probably won't be the latest version and may even be Python 2 instead of Python iii. You lot should bank check the version to make sure.

To find out which version of Python you have, open a concluding window and try the following commands:

                                                  # Cheque the organization Python version                  $ python --version                  # Check the Python two version                  $ python2 --version                  # Check the Python 3 version                  $ python3 --version                              

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

For example, if you already had Python iii.6.10 on your computer, then the python3 --version control would brandish that version number:

                                                  $                  python3 --version                  Python 3.six.x                              

You'll want to go the latest version of Python if your current version is in the Python ii.X series or is non the latest version of Python 3 available, which was 3.8.4 equally of this writing.

What Your Options Are

There are ii ways to install the official Python distribution on Linux:

  1. Install from a package manager: This is the almost common installation method on virtually Linux distributions. It involves running a command from the control line.

  2. Build from source code: This method is more than difficult than using a package manager. It involves running a series of commands from the command line as well as making certain you have the correct dependencies installed to compile the Python source code.

Not every Linux distribution has a package managing director, and not every parcel director has Python in its package repository. Depending on your operating arrangement, building Python from source code might be your simply option.

Which installation method you use mainly boils downward to whether your Linux Os has a package manager and whether yous need to control the details of the installation.

Linux Installation Recommendations

The most pop way to install Python on Linux is with your operating system's bundle manager, which is a good choice for most users. All the same, depending on your Linux distribution, Python may not be bachelor through a package manager. In this example, y'all'll demand to build Python from source code.

There are three main reasons that you lot might choose to build Python from source code:

  1. Yous can't download Python from your operating system's package manager.

  2. You need to command how Python gets compiled, such as when you lot desire to lower the memory footprint on embedded systems.

  3. You lot want to attempt out beta versions and release candidates of the latest and greatest version before information technology's by and large available.

To complete the installation on your Linux machine, discover your Linux distribution below and follow the steps provided.

How to Install on Ubuntu and Linux Mint

In this department, you lot'll learn how to install Python using Ubuntu's apt parcel director. If you lot'd similar to build Python from source code, skip ahead to the How to Build Python From Source Lawmaking section.

Depending on the version of the Ubuntu distribution you run, the process for setting up Python on your system will vary. Yous can determine your local Ubuntu version by running the post-obit command:

                                                  $                  lsb_release -a                  No LSB modules are available.                  Distributor ID: Ubuntu                  Description:    Ubuntu 16.04.4 LTS                  Release:        16.04                  Codename:       xenial                              

Follow the instructions beneath that lucifer the version number you lot see under Release in the panel output:

  • Ubuntu 18.04, Ubuntu 20.04 and above: Python 3.viii doesn't come by default on Ubuntu 18.04 and above, but information technology is available in the Universe repository. To install version iii.viii, open a concluding application and type the following commands:

                                                                  $                      sudo apt-get update                      $                      sudo apt-get install python3.8 python3-pip                                      

    Once the installation is complete, you can run Python 3.viii with the python3.8 command and pip with the pip3 command.

  • Linux Mint and Ubuntu 17 and below: Python three.eight isn't in the Universe repository, so you need to get it from a Personal Bundle Archive (PPA). For example, to install from the "deadsnakes" PPA, utilise the post-obit commands:

                                                                  $                      sudo add-apt-repository ppa:deadsnakes/ppa                      $                      sudo apt-get update                      $                      sudo apt-get install python3.8 python3-pip                                      

    In one case the installation is complete, you can run Python 3.viii with the python3.viii command and run pip with the pip3 control.

Congratulations! You now have Python 3 set on your machine!

How to Install on Debian Linux

Before you tin can install Python 3.8 on Debian, you'll demand to install the sudo command. To install it, execute the following commands in a terminal:

                                                  $                  su                  $                  apt-get install sudo                  $                  sudo vim /etc/sudoers                              

After that, open the /etc/sudoers file using the sudo vim command or your favorite text editor. Add the post-obit line of text to the stop of the file, replacing your_username with your bodily username:

                                your_username ALL=(ALL) ALL                              

Now you can skip alee to the How to Build Python From Source Lawmaking section to finish installing Python.

How to Install on openSUSE

Building from source is the virtually reliable way to ready Python on openSUSE. To practise that, you'll need to install the development tools, which can be done in YaST via the menus or by using zypper:

                                                  $                  sudu zypper install -t pattern devel_C_C                              

This might have a while to complete equally it installs over 150 packages. Once it'southward completed, skip ahead to the How to Build Python From Source Code section.

How to Install on CentOS and Fedora

Python 3.viii isn't bachelor in the CentOS and Fedora repositories, so you lot'll have to build Python from source code. Earlier you compile Python, though, you demand to brand certain your system is prepared.

First, update the yum parcel manager:

One time yum finishes updating, y'all can install the necessary build dependencies with the post-obit commands:

                                                  $                  sudo yum -y groupinstall                  "Evolution Tools"                  $                  sudo yum -y install gcc openssl-devel bzip2-devel libffi-devel                              

When everything is finished installing, skip ahead to the How to Build Python From Source Lawmaking section.

How to Install on Arch Linux

Arch Linux is adequately diligent about keeping up with Python releases. It'due south likely you already have the latest version. If not, use the following control to update Python:

When Python is finished updating, y'all should be all fix!

How to Build Python From Source Code

Sometimes your Linux distribution doesn't have the latest version of Python, or possibly yous merely desire to be able to build the latest, greatest version yourself. Here are the steps you lot need to take to build Python from source:

Step 1: Download the Source Code

To outset, you need to go the Python source code. Python.org makes this fairly straightforward. If yous become to the Downloads folio, and then you'll run into the latest source for Python 3 at the meridian. Just make sure you don't catch Legacy Python, Python 2!

When you select the Python iii version, you'll see a "Files" section at the lesser of the page. Select Gzipped source tarball and download information technology to your automobile. If yous prefer a command-line method, y'all can use wget to download the file to your current directory:

                                                        $                    wget https://world wide web.python.org/ftp/python/3.8.4/Python-three.8.4.tgz                                  

When the tarball finishes downloading, there are a few things y'all'll need to do to prepare your system for building Python.

Step 2: Set Your System

In that location are a few distro-specific steps involved in building Python from scratch. The goal of each step is the same on all distros, but you might need to translate to your distribution if it doesn't use apt-get:

  1. First, update your parcel manager and upgrade your packages:

                                                                        $                        sudo apt-get update                        $                        sudo apt-get upgrade                                          
  2. Next, make certain yous have all of the build requirements installed:

                                                                        # For apt-based systems (like Debian, Ubuntu, and Mint)                        $ sudo apt-get install -y make build-essential libssl-dev zlib1g-dev                        \                        libbz2-dev libreadline-dev libsqlite3-dev wget curlicue llvm                        \                        libncurses5-dev libncursesw5-dev xz-utils tk-dev                        # For yum-based systems (like CentOS)                        $ sudo yum -y groupinstall                        "Evolution Tools"                        $ sudo yum -y install gcc openssl-devel bzip2-devel libffi-devel                                          

    It's fine if you already take some of the requirements installed on your system. You can execute the above commands and whatever existing packages will not be overwritten.

Now that your system is ready to go, it's fourth dimension to get-go edifice Python!

Step 3: Build Python

  1. In one case yous have the prerequisites and the TAR file, y'all tin unpack the source into a directory. Note that the following command volition create a new directory called Python-3.eight.3 under the i you're in:

                                                                        $                        tar xvf Python-3.8.4.tgz                        $                                                cd                        Python-3.8.4                                          
  2. Now you need to run the ./configure tool to prepare the build:

                                                                        $                        ./configure --enable-optimizations --with-ensurepip=install                                          

    The enable-optimizations flag will enable some optimizations within Python to arrive run well-nigh 10 percent faster. Doing this may add twenty or thirty minutes to the compilation time. The with-ensurepip=install flag will install pip arranged with this installation.

  3. Adjacent, you build Python using make. The -j option merely tells brand to split the building into parallel steps to speed up the compilation. Even with the parallel builds, this step can take several minutes:

  4. Finally, you'll want to install your new version of Python. Yous'll use the altinstall target hither to avoid overwriting the arrangement Python. Since yous're installing into /usr/bin, y'all'll need to run equally root:

It might have a while to end installation. In one case it'south done, y'all can verify that Python is prepare correctly.

Step 4: Verify Your Installation

Examination that the python3.8 --version command returns the latest version:

                                                        $                    python3.viii --version                    Python three.eight.four                                  

If you see Python iii.8.four, then you're all set up!

If you accept some extra fourth dimension on your easily, you tin can too run the examination suite to make sure everything is working properly on your system.

To run the test suite, blazon the post-obit command:

You'll probably want to find something else to do for a while, as your computer will exist running tests for some fourth dimension. If all the tests pass, then you can be confident that your make-new Python build is working equally expected!

How to Install Python on iOS

The Pythonista app for iOS is a full-fledged Python development environment that you lot tin can run on your iPhone or iPad. It features a Python editor, technical documentation, and an interpreter all rolled into a single app.

Pythonista is surprisingly fun to use. It'south a great picayune tool when you're stuck without a laptop and want to piece of work on your Python skills on the go. It comes with the complete Python iii standard library and fifty-fifty includes full documentation that you lot tin can scan offline.

To gear up Pythonista, you need to download it from the iOS app store.

How to Install Python on Android

If you have an Android tablet or telephone and want to practice Python on the go, there are several options available. The one that nosotros found near reliably supports Python 3.8 is Pydroid 3.

Pydroid three features an interpreter that y'all can use for REPL sessions, and information technology also allows you to edit, save, and execute Python lawmaking.

You can download and install Pydroid 3 from the Google Play shop. In that location is a free version and also a paid Premium version that supports code prediction and code analysis.

Online Python Interpreters

If y'all want to endeavour out the examples in this tutorial without setting upward Python on your car, then there are several websites that offer an online Python interpreter:

  • Python.org Online Console
  • Repl.it
  • Python Fiddle
  • Trinket
  • Python Anywhere

These cloud-based Python interpreters may not be able to execute some of the more circuitous examples in this tutorial, just they're acceptable for running nearly of the code and may be a squeamish way to get started. More information on using these sites is presented in the side by side tutorial in this series.

Decision

Congratulations! Yous at present accept access to the latest version of Python for your system. Your Python journeying is just showtime.

In this tutorial you lot've learned how to:

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

You're now set to become started programming in Python! Exist sure to share your progress and any questions you lot may have in the comments below.

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