Watch At present This tutorial has a related video course created by the Real Python team. Lookout man it together with the written tutorial to deepen your agreement: Python Nuts: Setting Up Python

Installing or updating Python on your computer is the first step to becoming a Python programmer. At that place are a multitude of installation methods: yous can download official Python distributions from Python.org, install from a packet managing director, and even install specialized distributions for scientific computing, Internet of Things, and embedded systems.

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

In this tutorial you'll learn how to:

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

No thing what operating system yous're on, this tutorial has yous covered. Find your operating system beneath and swoop 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 lot'll learn how to check which version of Python, if any, is installed on your Windows figurer. You lot'll also learn which of the 3 installation methods yous should use.

How to Check Your Python Version on Windows

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

You tin can also use cmd.exe or Windows Terminal.

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

                                                  C:\>                  python --version                  Python 3.8.4                              

Using the --version switch volition show you the version that'south installed. Alternatively, yous tin can apply the -V switch:

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

In either case, if you see a version less than iii.8.4, which was the nearly 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, and so you can employ 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 command will work just if Python has been installed for your user account.

What Your Options Are

As mentioned before, at that place are three ways to install the official Python distribution on Windows:

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

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

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

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

If you lot want to install in the WSL, so you tin read the Linux department of this tutorial afterward you've installed the Linux distribution of your choice.

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

Limitations of the Microsoft Store Package

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

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

The central 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 apply Python for the first fourth dimension.

In addition to targeting beginning Pythonistas, the Microsoft Shop parcel has limitations that get in ill-suited for a professional evolution surroundings. In item, information technology does not take full write access to shared locations such equally TEMP or the registry.

Windows Installer Recommendations

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

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

How to Install From the Microsoft Store

If yous're new to Python and looking to get started rapidly, so the Microsoft Shop parcel is the best style to become upwardly and running without whatever fuss. Y'all tin install from the Microsoft Shop in ii steps.

Step 1: Open up the Python App Page in the Microsoft Shop

Open up the Microsoft Store app and search for Python.

You lot'll likely run into multiple versions that you tin choose to install:

The Microsoft Store search results for "Python"

Select Python iii.8, or the highest version number you lot run across available in the app, to open the installation page.

Alternatively, y'all can open PowerShell and type the post-obit command:

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

Footstep two: Install the Python App

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

  1. Click Get.

  2. Wait for the application to download. When it'southward finished downloading, the Become button volition be replaced with a button that says Install on my devices.

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

  4. Click Install Now and and so OK to offset the installation.

  5. If the installation was successful, then you'll see the bulletin "This product is installed" at the tiptop of the Microsoft Store page.

Congratulations! You at present 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 environment, installing from the full installer is the right pick. It offers more than customization and control over the installation than installing from the Microsoft Shop.

Y'all can install from the full installer in 2 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 page for Windows.

  2. Under the "Python Releases for Windows" heading, click the link for the Latest Python 3 Release - Python iii.x.ten. As of this writing, the latest version was Python iii.8.4.

  3. Gyre 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, and then you can aggrandize the box beneath to assistance you lot decide.

For Windows, you tin cull either the 32-scrap or the 64-bit installer. Here'southward the difference between the two:

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

  • On a 64-flake arrangement, either installer volition work for most purposes. The 32-bit version will generally use less memory, just the 64-chip version performs ameliorate for applications with intensive computation.

If yous're unsure which version to option, go with the 64-bit version.

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

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

Step two: Run the Installer

In one case you've chosen and downloaded an installer, run it by double-clicking on the downloaded file. A dialog box like the 1 beneath will announced:

Windows installation dialog

There are 4 things to discover about this dialog box:

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

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

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

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

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

Customize the installation to come across your needs using the options available on the dialog box. And then click Install Now. That's all there is to information technology!

Congratulations—yous now accept the latest version of Python 3 on your Windows machine!

How to Install Python on macOS

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

There are ii installation methods on macOS:

  1. The official installer
  2. The Homebrew packet manager

In this department, yous'll learn how to check which version of Python, if any, is installed on your macOS device. You lot'll likewise larn which of the ii installation methods you should use.

How to Check Your Python Version on a Mac

To cheque which Python version you lot have on your Mac, showtime open a command-line awarding, such every bit Last.

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

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

If y'all have Python on your system, then 1 or more of these commands should respond with a version number.

For example, if Python 3.6.ten were already gear up on your calculator, then the python3 command would brandish that version number:

                                                  $                  python3 --version                  Python three.6.ten                              
Yous'll want to get the latest version of Python if any of these weather condition is true:
  • None of the above commands returns a version number.
  • The only version you see displayed is in the Python 2.X series.
  • You have a version of Python iii that isn't the latest available, which was version 3.8.4 as of this writing.

What Your Options Are

In that location 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 parcel managing director: This method involves downloading and installing the Homebrew package manager if you don't already accept it installed, and 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 parcel manager 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 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 arrangement. The system version of Tcl/Tk may be outdated or missing entirely and could forestall you from importing the Tkinter module.

macOS Installer Recommendations

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

However, the Python distribution offered by Homebrew isn't controlled by the Python Software Foundation and could alter at any time. The most reliable method on macOS is to use the official installer, peculiarly if y'all 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. Information technology includes all the organization dependencies needed for developing applications with Python.

You can install from the official installer in ii steps.

Stride one: 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 iii Release - Python 3.x.x. Equally of this writing, the latest version was Python three.8.4.

  3. Scroll to the bottom and click macOS 64-chip installer to start the download.

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

Step 2: Run the Installer

Run the installer past double-clicking the downloaded file. You should see the post-obit window:

The macOS installation window.

Follow these steps to complete the installation:

  1. Press Continue a few times until you're asked to concord to the software license agreement. And so click Agree.

  2. You lot'll be shown a window that tells yous the install destination and how much space it will take. You nigh likely don't desire to modify the default location, then go alee and click Install to beginning the installation.

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

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

How to Install From Homebrew

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

Footstep 1: Install Homebrew

If you already have Homebrew installed, and so you lot can skip this step. If you don't accept Homebrew installed, so use the following process to install Homebrew:

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

  2. You should see a command for installing Homebrew virtually the tiptop of the page under the tile "Install Homebrew." This command will exist something like the following:

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

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

  3. Open up 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 Internet connection, it may take a few minutes to download all of Homebrew's required files. In one case the installation is complete, you'll terminate up back at the vanquish prompt in your last window.

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

Stride two: Install Python

Follow these steps to complete the installation with Homebrew:

  1. Open a final awarding.

  2. Type in the following control to upgrade Homebrew:

                                                                        $                        brew update                        &&                        mash upgrade                                          

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

Y'all can make certain everything went correctly by testing if you can access Python from the final:

  1. Open a terminal.

  2. Blazon pip3 and press Enter .

  3. You should encounter the help text from Python's pip package manager. If you go an mistake message running pip3, and so go through the install steps once more to brand sure yous have a working installation.

Congratulations—you 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 arrangement's package manager
  2. Building Python from source code

In this section, you'll acquire how to bank check which version of Python, if whatever, is on your Linux computer. You'll too learn which of the 2 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 exist the latest version and may fifty-fifty be Python 2 instead of Python 3. You lot 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:

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

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

For example, if you already had Python 3.6.ten on your computer, then the python3 --version command would display that version number:

                                                  $                  python3 --version                  Python 3.half-dozen.10                              

You lot'll want to become the latest version of Python if your electric current version is in the Python two.X series or is not the latest version of Python 3 available, which was three.8.iv every bit of this writing.

What Your Options Are

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

  1. Install from a package managing director: This is the most mutual installation method on near Linux distributions. It involves running a command from the command line.

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

Non every Linux distribution has a package director, and not every packet manager has Python in its package repository. Depending on your operating system, building Python from source code might be your only selection.

Which installation method you apply mainly boils down to whether your Linux Bone has a package manager and whether y'all need to control the details of the installation.

Linux Installation Recommendations

The most popular style to install Python on Linux is with your operating system'southward package director, which is a good pick for most users. However, depending on your Linux distribution, Python may non be available through a packet manager. In this case, you'll need to build Python from source code.

At that place are three main reasons that you might cull to build Python from source code:

  1. You can't download Python from your operating organization'south package director.

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

  3. You lot want to try out beta versions and release candidates of the latest and greatest version before it's more often than not available.

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

How to Install on Ubuntu and Linux Mint

In this section, y'all'll acquire how to install Python using Ubuntu's apt bundle managing director. If yous'd like 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 upward Python on your system will vary. Y'all tin decide 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:        xvi.04                  Codename:       xenial                              

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

  • Ubuntu 18.04, Ubuntu 20.04 and in a higher place: Python 3.viii doesn't come by default on Ubuntu 18.04 and to a higher place, merely it is available in the Universe repository. To install version three.viii, open up a last awarding and type the following commands:

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

    In one case the installation is complete, yous tin can run Python iii.8 with the python3.8 command and pip with the pip3 command.

  • Linux Mint and Ubuntu 17 and below: Python 3.eight isn't in the Universe repository, and so you need to get it from a Personal Parcel Annal (PPA). For case, to install from the "deadsnakes" PPA, use 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, yous can run Python 3.8 with the python3.8 control and run pip with the pip3 control.

Congratulations! You at present have Python 3 prepare on your automobile!

How to Install on Debian Linux

Before you can install Python three.8 on Debian, you'll need to install the sudo command. To install it, execute the following commands in a last:

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

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

                                your_username ALL=(ALL) ALL                              

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

How to Install on openSUSE

Edifice from source is the most reliable mode to prepare Python on openSUSE. To exercise that, you'll demand to install the development tools, which tin can exist 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 as it installs over 150 packages. Once it's completed, skip alee to the How to Build Python From Source Code section.

How to Install on CentOS and Fedora

Python iii.eight 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 need to make sure your system is prepared.

First, update the yum package managing director:

In one case yum finishes updating, you lot 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 alee to the How to Build Python From Source Lawmaking section.

How to Install on Arch Linux

Arch Linux is adequately diligent about keeping upwards with Python releases. Information technology's likely you already have the latest version. If not, utilise the post-obit control to update Python:

When Python is finished updating, y'all should exist all set!

How to Build Python From Source Code

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

Stride ane: Download the Source Code

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

When y'all select the Python 3 version, yous'll meet 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, you can utilize wget to download the file to your current directory:

                                                        $                    wget https://www.python.org/ftp/python/3.8.4/Python-3.eight.iv.tgz                                  

When the tarball finishes downloading, in that location are a few things you'll need to do to set up your organization for building Python.

Step 2: Prepare Your Arrangement

There 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 information technology doesn't use apt-go:

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

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

                                                                        # For apt-based systems (like Debian, Ubuntu, and Mint)                        $ sudo apt-go install -y make build-essential libssl-dev zlib1g-dev                        \                        libbz2-dev libreadline-dev libsqlite3-dev wget gyre 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 have some of the requirements installed on your organization. You can execute the above commands and whatsoever existing packages will non be overwritten.

Now that your organization is ready to become, it's time to start building Python!

Step three: Build Python

  1. Once yous have the prerequisites and the TAR file, you tin can unpack the source into a directory. Note that the following control will create a new directory called Python-3.eight.3 under the one yous're in:

                                                                        $                        tar xvf Python-3.8.four.tgz                        $                                                cd                        Python-three.viii.4                                          
  2. Now yous demand to run the ./configure tool to set the build:

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

    The enable-optimizations flag will enable some optimizations inside Python to go far run nigh 10 percentage faster. Doing this may add twenty or 30 minutes to the compilation fourth dimension. The with-ensurepip=install flag will install pip arranged with this installation.

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

  4. Finally, you'll want to install your new version of Python. Yous'll employ the altinstall target here to avoid overwriting the system Python. Since you're installing into /usr/bin, you'll need to run every bit root:

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

Step 4: Verify Your Installation

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

                                                        $                    python3.8 --version                    Python 3.eight.four                                  

If you meet Python iii.8.iv, then you lot're all set!

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

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

You'll probably want to notice something else to do for a while, as your computer will be running tests for some time. If all the tests pass, then you tin can be confident that your brand-new Python build is working as expected!

How to Install Python on iOS

The Pythonista app for iOS is a full-fledged Python evolution environs that you lot can run on your iPhone or iPad. Information technology features a Python editor, technical documentation, and an interpreter all rolled into a unmarried app.

Pythonista is surprisingly fun to use. It'southward a peachy footling tool when you're stuck without a laptop and want to piece of work on your Python skills on the become. It comes with the consummate Python 3 standard library and even includes total documentation that you lot can browse offline.

To prepare Pythonista, you demand to download information technology from the iOS app store.

How to Install Python on Android

If y'all have an Android tablet or phone and want to practise Python on the go, there are several options available. The 1 that we found well-nigh reliably supports Python 3.8 is Pydroid three.

Pydroid 3 features an interpreter that you lot tin can use for REPL sessions, and it also allows you to edit, save, and execute Python code.

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

Online Python Interpreters

If you want to try out the examples in this tutorial without setting up Python on your auto, then at that place 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 than complex examples in this tutorial, only they're adequate for running most of the code and may exist a nice manner to get started. More information on using these sites is presented in the next tutorial in this series.

Determination

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

In this tutorial yous've learned how to:

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

You're at present ready to get started programming in Python! Exist certain to share your progress and whatsoever questions you may have in the comments below.

Lookout man At present This tutorial has a related video course created by the Real Python squad. Scout it together with the written tutorial to deepen your agreement: Python Basics: Setting Upwardly Python