Sentry Now This tutorial has a related video class created by the Existent Python team. Watch it together with the written tutorial to deepen your understanding: Python Basics: Setting Upwardly Python

Installing or updating Python on your computer is the first step to becoming a Python programmer. In that location 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, Cyberspace of Things, and embedded systems.

This tutorial focuses on official distributions, as they're more often than not the best option for getting started with learning to plan in Python.

In this tutorial you'll acquire how to:

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

No thing what operating system you're on, this tutorial has you lot covered. Find your operating system beneath and dive in!

How to Install Python on Windows

In that location 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. Y'all'll besides larn which of the iii installation methods yous should employ.

How to Check Your Python Version on Windows

To check if you already take Python on your Windows car, offset open a command-line application, such as PowerShell.

Y'all can as well use cmd.exe or Windows Last.

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

                                                  C:\>                  python --version                  Python three.8.four                              

Using the --version switch will bear witness yous the version that's installed. Alternatively, you can employ the -V switch:

                                                  C:\>                  python -5                  Python three.8.four                              

In either case, if yous see a version less than iii.8.iv, which was the most recent version at the time of writing, so yous'll desire to upgrade your installation.

If you're interested in where the installation is located, then yous tin apply the where.exe control 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 command will work only if Python has been installed for your user business relationship.

What Your Options Are

Equally mentioned before, there are three ways to install the official Python distribution on Windows:

  1. Microsoft Shop parcel: 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. Total Installer: This approach 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 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 department, we'll focus on only the first ii options, which are the most pop 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 y'all've installed the Linux distribution of your choice.

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

Limitations of the Microsoft Store Package

The official Python documentation has this to say about the Microsoft Shop packet:

The Microsoft Store packet is an hands installable Python interpreter that is intended mainly for interactive employ, for instance, by students. (Source)

The primal takeaway here is that the Microsoft Shop package is "intended mainly for interactive employ." That is, the Microsoft Shop package is designed to be used by students and people learning to use Python for the first time.

In addition to targeting offset Pythonistas, the Microsoft Shop bundle has limitations that make it ill-suited for a professional person evolution environment. In item, information technology does not accept full write access to shared locations such equally TEMP or the registry.

Windows Installer Recommendations

If you're new to Python and focused primarily on learning the linguistic communication rather than building professional software, then you should install from the Microsoft Shop bundle. 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 Store policies, and yous tin control where the executable is installed and fifty-fifty 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 whatever fuss. You lot tin install from the Microsoft Shop in two steps.

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

Open the Microsoft Shop app and search for Python.

You'll likely see multiple versions that you tin choose to install:

The Microsoft Store search results for "Python"

Select Python three.8, or the highest version number you lot see available in the app, to open the installation folio.

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

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

Stride 2: Install the Python App

After you've selected the version to exist installed, follow these steps to complete the installation:

  1. Click Get.

  2. Wait for the awarding to download. When information technology's finished downloading, the Get button will exist replaced with a push 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 At present and then OK to kickoff the installation.

  5. If the installation was successful, and so you'll see the message "This product is installed" at the meridian of the Microsoft Store page.

Congratulations! Yous at present accept access to Python, including pip and IDLE!

How to Install From the Full Installer

For professional person developers who need a total-featured Python evolution environment, installing from the full installer is the right pick. 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 up a browser window and navigate to the Python.org Downloads folio for Windows.

  2. Under the "Python Releases for Windows" heading, click the link for the Latest Python 3 Release - Python 3.x.10. Every bit of this writing, the latest version was Python three.8.4.

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

If you aren't sure whether to select the 32-bit or the 64-chip installer, and then you can expand the box beneath to help y'all make up one's mind.

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

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

  • On a 64-bit system, either installer volition work for most purposes. The 32-bit version will by and large utilize less memory, but the 64-scrap version performs ameliorate for applications with intensive computation.

If you're unsure which version to option, get with the 64-fleck version.

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

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

Stride 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 find about this dialog box:

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

  2. The Customize installation push 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 ways every user on the machine volition accept access to the py.exe launcher. You tin uncheck this box to restrict Python to the current Windows user.

  4. The Add together Python 3.8 to PATH checkbox is unchecked by default. In that location are several reasons that you might non want Python on PATH, so make sure you sympathize the implications before you lot bank 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. And then click Install Now. That'due south all in that location is to it!

Congratulations—yous now have the latest version of Python iii on your Windows machine!

How to Install Python on macOS

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

In that location are ii installation methods on macOS:

  1. The official installer
  2. The Homebrew bundle manager

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

How to Check Your Python Version on a Mac

To check which Python version y'all take on your Mac, commencement open a command-line application, such equally Terminal.

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

                                                  # Check the organization Python version                  $ python --version                  # Bank check the Python 2 version                  $ python2 --version                  # Check the Python 3 version                  $ python3 --version                              

If you accept Python on your arrangement, so i or more of these commands should respond with a version number.

For instance, if Python 3.half dozen.10 were already prepare upward on your computer, and then the python3 command would display that version number:

                                                  $                  python3 --version                  Python iii.half dozen.x                              
Y'all'll want to get the latest version of Python if any of these conditions is truthful:
  • None of the higher up commands returns a version number.
  • The only version you lot see displayed is in the Python 2.X series.
  • You have a version of Python three that isn't the latest available, which was version three.eight.iv 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 car.

  2. The Homebrew package manager: This method involves downloading and installing the Homebrew package managing director 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 past the Python Software Foundation.

The distributions installed by the official installer and the Homebrew bundle 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 past 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 arrangement version of Tcl/Tk may exist outdated or missing entirely and could prevent y'all from importing the Tkinter module.

macOS Installer Recommendations

The Homebrew package manager is a popular method for installing Python on macOS considering information technology's piece of cake 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 tin can be automated with fustigate scripts.

However, the Python distribution offered past Homebrew isn't controlled by the Python Software Foundation and could alter at any fourth dimension. The most reliable method on macOS is to utilise 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 system dependencies needed for developing applications with Python.

You can install from the official installer in two steps.

Stride 1: Download the Official Installer

Follow these steps to download the total installer:

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

  2. Nether the "Python Releases for Mac OS X" heading, click the link for the Latest Python iii Release - Python 3.10.10. Every bit of this writing, the latest version was Python 3.eight.4.

  3. Curl to the lesser and click macOS 64-chip installer to start the download.

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

Pace 2: Run the Installer

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

The macOS installation window.

Follow these steps to complete the installation:

  1. Press Go on a few times until yous're asked to agree to the software license agreement. Then click Agree.

  2. You'll be shown a window that tells you the install destination and how much infinite it will have. You lot most likely don't want to change the default location, and then go ahead and click Install to start the installation.

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

Congratulations—you at present have the latest version of Python 3 on your macOS computer!

How to Install From Homebrew

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 pick. You tin can install from the Homebrew package director in 2 steps.

Step ane: Install Homebrew

If you already accept Homebrew installed, and so y'all tin can skip this step. If you don't have Homebrew installed, then employ the following process to install Homebrew:

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

  2. Y'all should run into a control for installing Homebrew nearly the summit of the page nether the tile "Install Homebrew." This control volition be something like the following:

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

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

  3. Open a terminal window and paste the command, then printing Enter . This will brainstorm the Homebrew installation.

  4. Enter your macOS user password when prompted.

Depending on your Internet connection, information technology may take a few minutes to download all of Homebrew's required files. Once the installation is complete, y'all'll end up back at the beat out prompt in your final window.

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

Step 2: Install Python

Follow these steps to consummate the installation with Homebrew:

  1. Open a terminal awarding.

  2. Type in the following command to upgrade Homebrew:

                                                                        $                        brew update                        &&                        mash upgrade                                          

Installing with Homebrew is now as straightforward as running the command brew install python3. This volition download and set the latest version of Python on your machine.

You lot can brand sure everything went correctly by testing if y'all can access Python from the terminal:

  1. Open a terminal.

  2. Blazon pip3 and printing Enter .

  3. You should see the aid text from Python'due south pip package manager. If y'all get an fault message running pip3, then get through the install steps over again to make certain you have a working installation.

Congratulations—y'all now have Python on your macOS system!

How to Install Python on Linux

At that place are two installation methods on Linux:

  1. Using your operating system'southward package manager
  2. Building Python from source code

In this department, you lot'll acquire how to check which version of Python, if any, is on your Linux computer. Yous'll also learn which of the two installation methods you should use.

How to Check Your Python Version on Linux

Many Linux distributions come up packaged with Python, but it probably won't exist the latest version and may fifty-fifty exist Python ii instead of Python 3. You should check the version to make sure.

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

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

If y'all have Python on your machine, then ane or more of these commands should reply with a version number.

For case, if you already had Python 3.six.10 on your calculator, and then the python3 --version command would display that version number:

                                                  $                  python3 --version                  Python iii.6.10                              

You'll want to get the latest version of Python if your current version is in the Python two.X series or is non the latest version of Python 3 available, which was iii.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 parcel managing director: This is the well-nigh common installation method on most Linux distributions. It involves running a control from the command line.

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

Not every Linux distribution has a package manager, and not every package director has Python in its package repository. Depending on your operating organization, edifice Python from source code might be your just selection.

Which installation method you employ mainly boils down to whether your Linux OS has a package managing director and whether you demand to control the details of the installation.

Linux Installation Recommendations

The most popular way to install Python on Linux is with your operating organization's package manager, which is a good selection for most users. Nevertheless, depending on your Linux distribution, Python may not be available through a bundle managing director. In this case, you'll need to build Python from source code.

There are three principal reasons that y'all might choose to build Python from source lawmaking:

  1. Yous can't download Python from your operating organization's parcel manager.

  2. You lot demand to command how Python gets compiled, such as when you lot want to lower the retention footprint on embedded systems.

  3. You desire 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, discover your Linux distribution below and follow the steps provided.

How to Install on Ubuntu and Linux Mint

In this section, you'll learn how to install Python using Ubuntu'due south apt package manager. If you lot'd like to build Python from source lawmaking, 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 volition vary. You can decide your local Ubuntu version by running the following 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 below that lucifer the version number you see under Release in the console output:

  • Ubuntu 18.04, Ubuntu xx.04 and above: Python 3.8 doesn't come by default on Ubuntu xviii.04 and above, but information technology is available in the Universe repository. To install version iii.8, open a last application and type the following commands:

                                                                  $                      sudo apt-go update                      $                      sudo apt-become install python3.eight python3-pip                                      

    Once the installation is complete, y'all tin run Python three.viii 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 you need to go it from a Personal Parcel Annal (PPA). For example, to install from the "deadsnakes" PPA, apply the post-obit commands:

                                                                  $                      sudo add-apt-repository ppa:deadsnakes/ppa                      $                      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 run pip with the pip3 command.

Congratulations! You at present have Python iii fix on your machine!

How to Install on Debian Linux

Before you can install Python 3.viii on Debian, you'll need to install the sudo control. To install information technology, execute the following commands in a final:

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

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

                                your_username ALL=(ALL) ALL                              

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

How to Install on openSUSE

Edifice from source is the most reliable way to gear up Python on openSUSE. To do that, y'all'll need to install the development tools, which can exist done in YaST via the menus or by using zypper:

                                                  $                  sudu zypper install -t blueprint devel_C_C                              

This might have a while to complete equally it installs over 150 packages. In one case it's completed, skip alee to the How to Build Python From Source Code section.

How to Install on CentOS and Fedora

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

Beginning, update the yum package manager:

Once yum finishes updating, you lot can install the necessary build dependencies with the following 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 Code section.

How to Install on Curvation Linux

Arch Linux is fairly diligent about keeping up with Python releases. It'southward probable you lot already have the latest version. If not, use the following command to update Python:

When Python is finished updating, you should exist all set!

How to Build Python From Source Code

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

Step 1: Download the Source Code

To first, you demand to get the Python source code. Python.org makes this adequately straightforward. If you lot get to the Downloads page, and then y'all'll see the latest source for Python 3 at the acme. Just make sure yous don't grab Legacy Python, Python 2!

When you select the Python three version, you'll come across a "Files" section at the bottom of the folio. Select Gzipped source tarball and download it to your machine. If yous prefer a command-line method, you can utilize wget to download the file to your current directory:

                                                        $                    wget https://www.python.org/ftp/python/three.8.four/Python-3.8.4.tgz                                  

When the tarball finishes downloading, at that place are a few things you'll need to do to prepare your system for edifice Python.

Footstep 2: Gear up Your Organization

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

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

                                                                        $                        sudo apt-get update                        $                        sudo apt-get upgrade                                          
  2. Adjacent, brand 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                        "Evolution Tools"                        $ sudo yum -y install gcc openssl-devel bzip2-devel libffi-devel                                          

    Information technology's fine if you already take some of the requirements installed on your organization. You can execute the above commands and any existing packages will non exist overwritten.

Now that your system is gear up to get, it's time to showtime edifice Python!

Step 3: Build Python

  1. Once you accept the prerequisites and the TAR file, you tin unpack the source into a directory. Annotation that the following control will create a new directory called Python-three.8.3 under the ane you're in:

                                                                        $                        tar xvf Python-3.eight.4.tgz                        $                                                cd                        Python-3.8.4                                          
  2. Now yous 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 go far run about x percent faster. Doing this may add xx or thirty minutes to the compilation time. The with-ensurepip=install flag will install pip bundled with this installation.

  3. Side by side, you lot build Python using brand. The -j option simply tells make to split the edifice into parallel steps to speed up the compilation. Even with the parallel builds, this pace can take several minutes:

  4. Finally, you'll want to install your new version of Python. You'll use the altinstall target here to avoid overwriting the system Python. Since you're installing into /usr/bin, y'all'll need to run as root:

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

Pace 4: Verify Your Installation

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

                                                        $                    python3.8 --version                    Python three.8.4                                  

If you lot encounter Python 3.8.4, and then you're all gear up!

If you take some extra fourth dimension on your hands, you can too run the test suite to make sure everything is working properly on your arrangement.

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

You lot'll probably desire to find something else to do for a while, as your calculator will exist running tests for some time. If all the tests laissez passer, then yous can exist confident that your brand-new Python build is working every bit expected!

How to Install Python on iOS

The Pythonista app 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.

Pythonista is surprisingly fun to use. Information technology's a great footling tool when you're stuck without a laptop and want to work on your Python skills on the become. It comes with the consummate Python 3 standard library and fifty-fifty includes full documentation that you lot tin scan offline.

To prepare upwards Pythonista, you demand to download it from the iOS app store.

How to Install Python on Android

If you have an Android tablet or phone and want to do Python on the go, in that location are several options available. The 1 that we establish well-nigh reliably supports Python three.viii is Pydroid 3.

Pydroid 3 features an interpreter that y'all can use for REPL sessions, and it also allows yous to edit, salve, and execute Python lawmaking.

Y'all tin download and install Pydroid 3 from the Google Play store. There is a gratuitous version and also a paid Premium version that supports code prediction and code analysis.

Online Python Interpreters

If you want to attempt out the examples in this tutorial without setting up Python on your machine, so there are several websites that offering 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, but they're adequate for running well-nigh of the code and may be a dainty style to get started. More information on using these sites is presented in the next tutorial in this series.

Conclusion

Congratulations! Y'all now accept admission to the latest version of Python for your system. Your Python journeying is just offset.

In this tutorial y'all've learned how to:

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

You're now ready to get started programming in Python! Be certain to share your progress and whatever questions you may have in the comments beneath.

Picket Now This tutorial has a related video course created by the Existent Python team. Picket it together with the written tutorial to deepen your agreement: Python Nuts: Setting Up Python