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

Installing or updating Python on your figurer is the showtime step to becoming a Python programmer. There are a multitude of installation methods: you tin can download official Python distributions from Python.org, install from a bundle manager, and fifty-fifty install specialized distributions for scientific computing, Internet of Things, and embedded systems.

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

In this tutorial yous'll learn how to:

  • Check which version of Python, if whatsoever, is installed on your car
  • Install or update Python on Windows, macOS, and Linux
  • Utilise Python on mobile devices similar phones or tablets
  • Use Python on the Web with online interpreters

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

How to Bank check Your Python Version on Windows

To check if you already take Python on your Windows machine, first open a control-line application, such as PowerShell.

You lot tin can also utilize cmd.exe or Windows Concluding.

With the command line open up, blazon in the following command and press Enter :

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

Using the --version switch will testify you the version that's installed. Alternatively, yous can use the -V switch:

                                                  C:\>                  python -V                  Python 3.8.4                              

In either case, if you run across a version less than 3.8.4, which was the nigh contempo version at the time of writing, then yous'll want to upgrade your installation.

If you're interested in where the installation is located, then you can use 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 volition work only if Python has been installed for your user account.

What Your Options Are

Equally mentioned earlier, there are 3 ways to install the official Python distribution on Windows:

  1. Microsoft Shop bundle: The almost 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 arroyo involves downloading Python direct from the Python.org website. This is recommended for intermediate and advanced developers who need more control during the setup process.

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

In this section, nosotros'll focus on only the beginning 2 options, which are the most pop installation methods in a Windows surround.

If yous desire to install in the WSL, then you can read the Linux section of this tutorial after you've installed the Linux distribution of your selection.

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

Limitations of the Microsoft Store Package

The official Python documentation has this to say most the Microsoft Store bundle:

The Microsoft Store package 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 Shop package is "intended mainly for interactive use." That is, the Microsoft Shop package is designed to exist used by students and people learning to use Python for the beginning time.

In addition to targeting beginning Pythonistas, the Microsoft Store bundle has limitations that arrive ill-suited for a professional evolution environment. In particular, information technology does not have total write access to shared locations such as TEMP or the registry.

Windows Installer Recommendations

If you're new to Python and focused primarily on learning the language rather than edifice professional software, then you should install from the Microsoft Shop packet. 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 right choice. Your installation won't be express by Microsoft Store policies, and you tin 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 become started quickly, then the Microsoft Store bundle is the best way to get upwards and running without whatever fuss. You lot tin install from the Microsoft Store in 2 steps.

Step one: Open the Python App Folio in the Microsoft Store

Open the Microsoft Store app and search for Python.

You'll probable meet multiple versions that you tin can choose to install:

The Microsoft Store search results for "Python"

Select Python iii.viii, or the highest version number you see available in the app, to open the installation page.

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

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

Step 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's finished downloading, the Get push will 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 then OK to start the installation.

  5. If the installation was successful, and so y'all'll see the message "This product is installed" at the meridian 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 demand a full-featured Python development surround, installing from the full installer is the right choice. It offers more customization and command over the installation than installing from the Microsoft Store.

Y'all tin can install from the total installer in two steps.

Stride 1: Download the Total 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 3.10.x. Equally of this writing, the latest version was Python three.8.four.

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

If you lot aren't sure whether to select the 32-bit or the 64-bit installer, then yous tin can expand the box below to help you decide.

For Windows, you can choose either the 32-fleck or the 64-flake installer. Here's the difference between the two:

  • If your system has a 32-bit processor, then y'all should cull the 32-chip installer. If you attempt to install the 64-bit version on a 32-bit processor, so you'll get an error at the offset and the install will fail.

  • On a 64-bit system, either installer volition piece of work for about purposes. The 32-fleck version will mostly use less memory, but the 64-chip version performs better for applications with intensive computation.

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

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

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

Pace 2: Run the Installer

Once y'all've called and downloaded an installer, run it past double-clicking on the downloaded file. A dialog box similar the 1 below will announced:

Windows installation dialog

There are 4 things to notice about this dialog box:

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

  2. The Customize installation push tin can be used to customize the installation location and which additional features get installed, including pip and IDLE.

  3. The Install launcher for all users (recommended) checkbox is checked default. This means every user on the motorcar will have 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 past default. There are several reasons that you might non want Python on PATH, so make certain you sympathize the implications before you 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 so click Install Now. That's all there is to information technology!

Congratulations—you at present have the latest version of Python 3 on your Windows auto!

How to Install Python on macOS

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

There are two installation methods on macOS:

  1. The official installer
  2. The Homebrew packet manager

In this department, you'll learn how to bank check which version of Python, if any, is installed on your macOS device. Y'all'll also learn which of the two installation methods you should utilize.

How to Check Your Python Version on a Mac

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

With the control line open, type in 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 you have Python on your system, and so one or more of these commands should reply with a version number.

For example, if Python iii.6.10 were already prepare on your figurer, then the python3 command would display that version number:

                                                  $                  python3 --version                  Python three.6.10                              
You'll want to become the latest version of Python if any of these conditions is true:
  • None of the above commands returns a version number.
  • The simply version you run into displayed is in the Python ii.Ten serial.
  • You have a version of Python 3 that isn't the latest available, which was version 3.8.4 every bit of this writing.

What Your Options Are

At that place 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 bundle manager: This method involves downloading and installing the Homebrew package manager if you don't already accept information technology installed, and and so typing a command into a terminal application.

Both the official installer and the Homebrew parcel director volition piece of work, only simply the official installer is maintained by the Python Software Foundation.

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

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 function of Python.

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

macOS Installer Recommendations

The Homebrew package manager 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 get to a website. Because Homebrew is a command-line utility, it can be automated with bash scripts.

Yet, the Python distribution offered by Homebrew isn't controlled past the Python Software Foundation and could alter at any fourth dimension. The about reliable method on macOS is to use the official installer, especially if you lot plan on doing Python GUI programming with Tkinter.

How to Install From the Official Installer

Installing Python from the official installer is the nigh reliable installation method on macOS. It includes all the system dependencies needed for developing applications with Python.

You tin can install from the official installer in ii steps.

Step ane: 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. Under the "Python Releases for Mac Os X" heading, click the link for the Latest Python iii Release - Python three.10.x. Every bit of this writing, the latest version was Python three.8.iv.

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

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

Step ii: 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 consummate the installation:

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

  2. You'll be shown a window that tells you lot the install destination and how much infinite it will have. You well-nigh probable don't want to change the default location, then become alee and click Install to kickoff the installation.

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

Congratulations—yous 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, specially those who won't be using Python to develop graphical user interfaces with the Tkinter module, the Homebrew bundle director is a adept pick. You can install from the Homebrew package manager in two steps.

Step 1: Install Homebrew

If you already have Homebrew installed, then y'all tin can skip this stride. If yous don't take Homebrew installed, and then use the following procedure to install Homebrew:

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

  2. You should meet a control for installing Homebrew most the top of the page under the tile "Install Homebrew." This command will be something similar the post-obit:

                                                                        $                        /bin/fustigate -c                        "                        $(whorl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/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, so printing Enter . This will begin the Homebrew installation.

  4. Enter your macOS user countersign when prompted.

Depending on your Net connection, it may take a few minutes to download all of Homebrew's required files. Once the installation is complete, you lot'll end up back at the crush prompt in your concluding window.

At present that Homebrew is installed, you're set up to install Python.

Step 2: Install Python

Follow these steps to complete the installation with Homebrew:

  1. Open a terminal awarding.

  2. Type in the following command to upgrade Homebrew:

                                                                        $                        brew update                        &&                        brew upgrade                                          

Installing with Homebrew is now equally straightforward as running the control brew install python3. This will download and ready the latest version of Python on your machine.

You can brand certain everything went correctly by testing if y'all can access Python from the last:

  1. Open a terminal.

  2. Blazon pip3 and press Enter .

  3. Yous should see the assistance text from Python's pip package managing director. If you go an error message running pip3, and then become through the install steps once more to make certain y'all accept a working installation.

Congratulations—you at present accept Python on your macOS organization!

How to Install Python on Linux

There are ii installation methods on Linux:

  1. Using your operating system's package director
  2. Edifice Python from source code

In this section, yous'll learn how to check which version of Python, if any, is on your Linux calculator. You'll besides learn which of the two installation methods yous should utilise.

How to Bank check Your Python Version on Linux

Many Linux distributions come up packaged with Python, merely it probably won't be the latest version and may even be Python two instead of Python three. You should check the version to make sure.

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

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

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

For instance, if you lot already had Python iii.6.10 on your figurer, then the python3 --version command would display that version number:

                                                  $                  python3 --version                  Python 3.6.10                              

You'll desire to get the latest version of Python if your current version is in the Python 2.X serial or is not the latest version of Python 3 available, which was three.8.4 as of this writing.

What Your Options Are

In that location are 2 ways to install the official Python distribution on Linux:

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

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

Not every Linux distribution has a packet manager, and not every package manager has Python in its package repository. Depending on your operating system, edifice Python from source lawmaking might exist your only option.

Which installation method you use mainly boils down to whether your Linux OS has a bundle director and whether you 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's package managing director, which is a good option for most users. However, depending on your Linux distribution, Python may not be available through a package manager. In this case, you'll need to build Python from source code.

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

  1. You can't download Python from your operating system'southward package manager.

  2. Yous need to control how Python gets compiled, such every bit when you want to lower the memory footprint on embedded systems.

  3. Yous desire to try out beta versions and release candidates of the latest and greatest version before information technology'southward 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 bundle manager. If you'd like to build Python from source lawmaking, skip ahead to the How to Build Python From Source Code department.

Depending on the version of the Ubuntu distribution you lot run, the process for setting up Python on your organization will vary. You tin determine your local Ubuntu version by running the following command:

                                                  $                  lsb_release -a                  No LSB modules are bachelor.                  Distributor ID: Ubuntu                  Description:    Ubuntu sixteen.04.4 LTS                  Release:        sixteen.04                  Codename:       xenial                              

Follow the instructions below that match the version number yous see under Release in the panel output:

  • Ubuntu xviii.04, Ubuntu twenty.04 and in a higher place: Python 3.8 doesn't come by default on Ubuntu xviii.04 and above, but it is available in the Universe repository. To install version 3.8, open a final application and type the following commands:

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

    Once the installation is consummate, you lot can run Python iii.eight with the python3.eight control and pip with the pip3 control.

  • Linux Mint and Ubuntu 17 and beneath: Python 3.eight isn't in the Universe repository, so you need to go it from a Personal Bundle Annal (PPA). For case, to install from the "deadsnakes" PPA, apply the post-obit commands:

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

    Once the installation is complete, y'all can run Python three.8 with the python3.8 command and run pip with the pip3 command.

Congratulations! You at present have Python three set on your machine!

How to Install on Debian Linux

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

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

After that, open the /etc/sudoers file using the sudo vim control or your favorite text editor. Add together 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 tin skip ahead to the How to Build Python From Source Code department to finish installing Python.

How to Install on openSUSE

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

                                                  $                  sudu zypper install -t pattern devel_C_C                              

This might take a while to consummate as it installs over 150 packages. Once it's completed, skip ahead 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, so you'll take to build Python from source code. Before you compile Python, though, you need to make sure your system is prepared.

First, 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 about keeping up with Python releases. It'southward likely you already take the latest version. If not, use the following command to update Python:

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

How to Build Python From Source Lawmaking

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

Step one: Download the Source Code

To start, you need to become the Python source lawmaking. Python.org makes this fairly straightforward. If you lot go to the Downloads page, then you'll encounter the latest source for Python 3 at the superlative. Simply brand sure yous don't grab Legacy Python, Python 2!

When y'all select the Python three version, you'll see a "Files" section at the lesser of the page. Select Gzipped source tarball and download it to your machine. If you lot prefer a control-line method, you tin can use wget to download the file to your current directory:

                                                        $                    wget https://www.python.org/ftp/python/iii.8.4/Python-3.8.four.tgz                                  

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

Step ii: Set Your System

At that place 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 interpret to your distribution if information technology doesn't use apt-become:

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

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

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

    It'southward fine if you already have some of the requirements installed on your organisation. You can execute the above commands and any existing packages will not be overwritten.

Now that your system is ready to go, it's time to beginning edifice Python!

Step 3: Build Python

  1. Once you accept the prerequisites and the TAR file, you lot can unpack the source into a directory. Annotation that the post-obit command will create a new directory chosen Python-3.8.iii nether the one you lot're in:

                                                                        $                        tar xvf Python-3.8.four.tgz                        $                                                cd                        Python-3.viii.iv                                          
  2. Now you lot need to run the ./configure tool to prepare the build:

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

    The enable-optimizations flag will enable some optimizations inside Python to make it run most ten per centum faster. Doing this may add twenty or 30 minutes to the compilation time. The with-ensurepip=install flag volition install pip bundled with this installation.

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

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

It might take a while to stop installation. Once it's washed, you tin can verify that Python is fix correctly.

Step 4: Verify Your Installation

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

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

If you see Python 3.8.4, and then you're all ready!

If you have some actress time on your hands, you tin can also run the examination suite to make sure everything is working properly on your organization.

To run the examination suite, blazon the following command:

You'll probably want to detect something else to do for a while, as your computer volition be running tests for some time. If all the tests laissez passer, and then yous can be confident that your make-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 nifty petty tool when you're stuck without a laptop and desire to work on your Python skills on the go. It comes with the consummate Python 3 standard library and even includes full documentation that you lot can browse offline.

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

How to Install Python on Android

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

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

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

Online Python Interpreters

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

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

These deject-based Python interpreters may non exist able to execute some of the more than complex examples in this tutorial, just they're acceptable for running virtually of the lawmaking and may be a nice fashion to become started. More information on using these sites is presented in the side by side tutorial in this series.

Conclusion

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

In this tutorial you've learned how to:

  • Cheque 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 similar phones or tablets
  • Use Python on the Web with online interpreters

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

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