Lookout Now This tutorial has a related video class created past the Real Python team. Watch information technology together with the written tutorial to deepen your understanding: Python Nuts: Setting Up Python

Installing or updating Python on your estimator is the starting time 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 bundle manager, and even install specialized distributions for scientific calculating, Cyberspace of Things, and embedded systems.

This tutorial focuses on official distributions, every bit they're generally the all-time option for getting started with learning to program in Python.

In this tutorial you'll learn how to:

  • Bank check which version of Python, if whatever, is installed on your auto
  • 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 arrangement 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 Shop
  2. The full installer
  3. Windows Subsystem for Linux

In this section, y'all'll learn how to check which version of Python, if any, is installed on your Windows estimator. You'll also learn which of the three installation methods you should utilise.

How to Check Your Python Version on Windows

To check if yous already have Python on your Windows machine, beginning open a command-line application, such every bit PowerShell.

You lot can besides apply cmd.exe or Windows Terminal.

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

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

Using the --version switch will evidence you the version that'due south installed. Alternatively, you can use the -V switch:

                                                  C:\>                  python -V                  Python 3.8.iv                              

In either instance, if y'all see a version less than 3.eight.4, which was the almost recent version at the fourth dimension of writing, then you'll want to upgrade your installation.

If you lot'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                              

Annotation that the where.exe control will piece of work just if Python has been installed for your user business relationship.

What Your Options Are

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

  1. Microsoft Shop package: The well-nigh straightforward installation method on Windows involves installing from the Microsoft Store app. This is recommended for beginner Python users looking for an like shooting fish in a barrel-to-set-upward interactive experience.

  2. Total Installer: This approach involves downloading Python straight from the Python.org website. This is recommended for intermediate and avant-garde developers who demand more control during the setup process.

  3. Windows Subsystem for Linux (WSL): The WSL allows you to run a Linux environment direct 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 2 options, which are the near popular installation methods in a Windows surround.

If you want to install in the WSL, then you lot tin can read the Linux section of this tutorial subsequently you lot've installed the Linux distribution of your choice.

The 2 official Python installers for Windows aren't identical. The Microsoft Store package has some of import limitations.

Limitations of the Microsoft Shop Package

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

The Microsoft Store parcel 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 Shop package is designed to be used past students and people learning to use Python for the first fourth dimension.

In add-on to targeting start Pythonistas, the Microsoft Store package has limitations that make information technology ill-suited for a professional development environment. In particular, information technology does not have full write admission to shared locations such equally 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 lot 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 correct selection. Your installation won't be limited by Microsoft Shop policies, and yous tin 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 fashion to get upward and running without any fuss. You tin can install from the Microsoft Store in two steps.

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

Open the Microsoft Store app and search for Python.

Y'all'll likely see multiple versions that you can cull to install:

The Microsoft Store search results for "Python"

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

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

If you lot don't already have a version of Python on your system, so when you press Enter , the Microsoft Store volition automatically launch and take you lot to the latest version of Python in the shop.

Step two: Install the Python App

After y'all'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 information technology's finished downloading, the Get 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 similar to complete the installation.

  4. Click Install At present and then OK to start the installation.

  5. If the installation was successful, then you'll run across the bulletin "This production is installed" at the top of the Microsoft Shop folio.

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 evolution environs, installing from the full installer is the right choice. It offers more customization and control over the installation than installing from the Microsoft Shop.

You lot can install from the full installer in ii 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 folio for Windows.

  2. Nether the "Python Releases for Windows" heading, click the link for the Latest Python iii Release - Python 3.x.x. Equally of this writing, the latest version was Python three.eight.four.

  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 yous decide.

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

  • If your organization has a 32-bit processor, and then you should choose the 32-fleck installer. If you attempt to install the 64-bit version on a 32-chip processor, and then y'all'll get an error at the beginning and the install will neglect.

  • On a 64-bit system, either installer volition work for near purposes. The 32-bit version will more often than not utilize less memory, simply the 64-bit version performs amend for applications with intensive computation.

If you're unsure which version to selection, become 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 two: Run the Installer

Once y'all've chosen and downloaded an installer, run it by double-clicking on the downloaded file. A dialog box like the i below will announced:

Windows installation dialog

There are four things to find about this dialog box:

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

  2. The Customize installation button can be used to customize the installation location and which boosted 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 volition have access to the py.exe launcher. Y'all can uncheck this box to restrict Python to the electric current Windows user.

  4. The Add Python 3.eight to PATH checkbox is unchecked past default. There are several reasons that you might non want Python on PATH, so make sure you sympathise the implications before you bank check this box.

The full installer gives you lot total command over the installation process.

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

Congratulations—you lot at present have 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 example 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, yous'll learn how to check which version of Python, if whatsoever, is installed on your macOS device. You'll also learn which of the two installation methods y'all should utilise.

How to Bank check Your Python Version on a Mac

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

With the command line open up, type in the post-obit commands:

                                                  # Check the system Python version                  $ python --version                  # Check the Python ii version                  $ python2 --version                  # Check the Python 3 version                  $ python3 --version                              

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

For example, if Python 3.vi.10 were already set up on your estimator, then the python3 command would display that version number:

                                                  $                  python3 --version                  Python 3.6.10                              
You lot'll desire to become the latest version of Python if any of these conditions is truthful:
  • None of the above commands returns a version number.
  • The only version you see displayed is in the Python 2.X serial.
  • You take a version of Python 3 that isn't the latest available, which was version 3.eight.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 information technology installed, so typing a command into a final application.

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

The distributions installed past the official installer and the Homebrew parcel 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 information technology's piece of cake to manage from the command line and offers commands to upgrade Python without having to get to a website. Considering Homebrew is a command-line utility, it can be automatic with fustigate scripts.

However, the Python distribution offered by Homebrew isn't controlled past the Python Software Foundation and could modify at any time. The well-nigh reliable method on macOS is to use the official installer, especially if you 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 organisation 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:

  1. Open up 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 3 Release - Python three.x.10. As of this writing, the latest version was Python iii.eight.4.

  3. Curl to the bottom and click macOS 64-bit installer to start the download.

When the installer is finished downloading, move on to the side by side pace.

Step 2: Run the Installer

Run the installer by double-clicking the downloaded file. You should see the following window:

The macOS installation window.

Follow these steps to complete the installation:

  1. Press Proceed a few times until you're asked to concord to the software license understanding. Then click Agree.

  2. You'll be shown a window that tells yous the install destination and how much space information technology will take. You lot about likely don't want to change the default location, so go ahead and click Install to start the installation.

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

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

How to Install From Homebrew

For users who need to install from the control line, particularly those who won't be using Python to develop graphical user interfaces with the Tkinter module, the Homebrew package director is a good pick. Y'all tin can install from the Homebrew parcel manager in two steps.

Step one: Install Homebrew

If you already have Homebrew installed, then you can skip this step. If you don't have Homebrew installed, then utilize the following procedure to install Homebrew:

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

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

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

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

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

  4. Enter your macOS user countersign when prompted.

Depending on your Internet connection, information technology may take a few minutes to download all of Homebrew'southward required files. Once the installation is complete, you'll cease up back at the shell prompt in your final window.

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

Footstep 2: Install Python

Follow these steps to complete the installation with Homebrew:

  1. Open a terminal awarding.

  2. Type in the post-obit control to upgrade Homebrew:

                                                                        $                        brew update                        &&                        brew upgrade                                          

Installing with Homebrew is now as straightforward as running the control mash install python3. This will download and fix the latest version of Python on your car.

You can make sure everything went correctly by testing if you can access Python from the terminal:

  1. Open a last.

  2. Type pip3 and press Enter .

  3. You should see the assistance text from Python'southward pip package director. If you get an error message running pip3, then become through the install steps again to make certain you have a working installation.

Congratulations—you now have Python on your macOS organisation!

How to Install Python on Linux

At that place are 2 installation methods on Linux:

  1. Using your operating system's parcel manager
  2. Edifice Python from source code

In this section, y'all'll larn how to check which version of Python, if any, is on your Linux reckoner. You'll also learn which of the two installation methods you should use.

How to Check Your Python Version on Linux

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. Y'all should check the version to make sure.

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

                                                  # Check the system Python version                  $ python --version                  # Check the Python ii version                  $ python2 --version                  # Cheque the Python 3 version                  $ python3 --version                              

If you have Python on your machine, and 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 estimator, then the python3 --version command would display that version number:

                                                  $                  python3 --version                  Python three.6.10                              

Y'all'll want to get the latest version of Python if your electric current version is in the Python 2.X serial or is non the latest version of Python iii available, which was iii.viii.4 equally of this writing.

What Your Options Are

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

  1. Install from a package manager: This is the most mutual installation method on most Linux distributions. Information technology involves running a control from the command line.

  2. Build from source lawmaking: This method is more difficult than using a package manager. It involves running a series of commands from the command line equally well as making sure y'all have the right dependencies installed to compile the Python source code.

Not every Linux distribution has a package manager, and not every bundle director has Python in its package repository. Depending on your operating system, building Python from source lawmaking might exist your just option.

Which installation method you apply mainly boils downwardly to whether your Linux OS has a bundle manager and whether you need to control the details of the installation.

Linux Installation Recommendations

The nearly popular style to install Python on Linux is with your operating system's package manager, which is a good choice for most users. Nonetheless, depending on your Linux distribution, Python may not be bachelor through a parcel manager. In this instance, you'll need to build Python from source code.

There are three primary reasons that you might choose to build Python from source lawmaking:

  1. Y'all tin can't download Python from your operating system's package manager.

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

  3. You want to endeavor out beta versions and release candidates of the latest and greatest version earlier it's generally available.

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

How to Install on Ubuntu and Linux Mint

In this section, y'all'll learn how to install Python using Ubuntu's apt package manager. If you'd like to build Python from source code, skip ahead to the How to Build Python From Source Code section.

Depending on the version of the Ubuntu distribution you run, the procedure for setting up Python on your system will vary. You lot can make up one's mind your local Ubuntu version past running the following command:

                                                  $                  lsb_release -a                  No LSB modules are available.                  Distributor ID: Ubuntu                  Clarification:    Ubuntu xvi.04.4 LTS                  Release:        16.04                  Codename:       xenial                              

Follow the instructions below that friction match the version number you see under Release in the console output:

  • Ubuntu eighteen.04, Ubuntu 20.04 and above: Python 3.viii doesn't come by default on Ubuntu 18.04 and above, just it is available in the Universe repository. To install version 3.8, open a terminal application and type the post-obit commands:

                                                                  $                      sudo apt-get update                      $                      sudo apt-go install python3.viii python3-pip                                      

    One time the installation is complete, yous tin can run Python 3.8 with the python3.8 command and pip with the pip3 command.

  • Linux Mint and Ubuntu 17 and beneath: Python 3.8 isn't in the Universe repository, so yous need to get information technology from a Personal Package Archive (PPA). For instance, to install from the "deadsnakes" PPA, apply the following commands:

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

    In one case the installation is consummate, you can run Python 3.8 with the python3.viii command and run pip with the pip3 command.

Congratulations! You now have Python three fix on your machine!

How to Install on Debian Linux

Earlier yous tin can install Python iii.8 on Debian, you lot'll need to install the sudo command. To install information technology, execute the following commands in a terminal:

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

After that, open the /etc/sudoers file using the sudo vim command or your favorite text editor. Add together the following line of text to the end of the file, replacing your_username with your actual username:

                                your_username ALL=(ALL) ALL                              

Now you can skip alee to the How to Build Python From Source Code section to terminate installing Python.

How to Install on openSUSE

Building from source is the most reliable way to prepare up Python on openSUSE. To do that, you lot'll demand to install the development tools, which tin be done in YaST via the menus or past using zypper:

                                                  $                  sudu zypper install -t blueprint devel_C_C                              

This might take a while to complete every bit information technology installs over 150 packages. In one case it'south completed, skip alee to the How to Build Python From Source Lawmaking department.

How to Install on CentOS and Fedora

Python 3.8 isn't available in the CentOS and Fedora repositories, then you'll have to build Python from source code. Before you compile Python, though, you need to make sure your system is prepared.

Start, update the yum package manager:

Once yum finishes updating, you can install the necessary build dependencies with the following commands:

                                                  $                  sudo yum -y groupinstall                  "Development 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 Code section.

How to Install on Arch Linux

Arch Linux is fairly diligent most keeping upward with Python releases. It's likely you already have the latest version. If non, use the following command to update Python:

When Python is finished updating, yous should exist all gear up!

How to Build Python From Source Lawmaking

Sometimes your Linux distribution doesn't have the latest version of Python, or maybe you just want to be able to build the latest, greatest version yourself. Hither are the steps you need to take to build Python from source:

Step i: Download the Source Code

To start, you need to get the Python source code. Python.org makes this fairly straightforward. If you go to the Downloads page, so y'all'll encounter the latest source for Python 3 at the top. Just make sure you don't grab Legacy Python, Python ii!

When yous select the Python 3 version, yous'll see a "Files" section at the bottom of the page. Select Gzipped source tarball and download it to your machine. If yous prefer a command-line method, y'all can apply wget to download the file to your electric current directory:

                                                        $                    wget https://www.python.org/ftp/python/3.viii.four/Python-3.8.iv.tgz                                  

When the tarball finishes downloading, there are a few things you'll need to do to set up your system for building Python.

Step 2: Prepare Your System

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

  1. Kickoff, update your package managing director and upgrade your packages:

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

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

    It'south fine if y'all already have some of the requirements installed on your system. Yous can execute the above commands and any existing packages will not be overwritten.

Now that your system is prepare to go, information technology'southward time to start edifice Python!

Step 3: Build Python

  1. Once y'all have the prerequisites and the TAR file, you can unpack the source into a directory. Note that the following command will create a new directory chosen Python-3.viii.iii under the ane you're in:

                                                                        $                        tar xvf Python-3.8.4.tgz                        $                                                cd                        Python-3.eight.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 make information technology run about 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. Next, yous build Python using brand. The -j choice but tells brand to divide the building into parallel steps to speed upwards the compilation. Even with the parallel builds, this footstep can take several minutes:

  4. Finally, yous'll desire to install your new version of Python. Y'all'll apply the altinstall target here to avoid overwriting the arrangement Python. Since you're installing into /usr/bin, you'll need to run equally root:

Information technology might take a while to finish installation. Once it'southward washed, you tin verify that Python is fix correctly.

Step four: Verify Your Installation

Test that the python3.8 --version control returns the latest version:

                                                        $                    python3.8 --version                    Python 3.viii.4                                  

If you run into Python 3.8.iv, and then you're all set!

If you take some extra time on your hands, you can also run the examination suite to make sure everything is working properly on your system.

To run the test suite, blazon the following command:

You'll probably want to discover something else to do for a while, as your computer volition be running tests for some time. If all the tests laissez passer, then yous 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 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's a great little tool when you lot'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 even includes total documentation that you can browse offline.

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

How to Install Python on Android

If you accept 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 Pydroid iii.

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

You lot tin download and install Pydroid 3 from the Google Play store. There is a free version and also a paid Premium version that supports lawmaking prediction and code analysis.

Online Python Interpreters

If you want to try out the examples in this tutorial without setting upwards Python on your machine, then there are several websites that offering an online Python interpreter:

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

These deject-based Python interpreters may not exist able to execute some of the more complex examples in this tutorial, but they're adequate for running most of the code and may exist a dainty way to go started. More information on using these sites is presented in the next tutorial in this serial.

Conclusion

Congratulations! You now have access to the latest version of Python for your system. Your Python journey is just beginning.

In this tutorial you'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 like phones or tablets
  • Utilise Python on the Web with online interpreters

Y'all're at present ready to become started programming in Python! Exist sure to share your progress and any questions yous may have in the comments below.

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