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

Installing or updating Python on your computer is the starting time step to becoming a Python programmer. In that location are a multitude of installation methods: you tin can download official Python distributions from Python.org, install from a package managing director, and even install specialized distributions for scientific computing, Cyberspace of Things, and embedded systems.

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

In this tutorial you'll acquire how to:

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

No matter what operating system y'all're on, this tutorial has you covered. Find your operating arrangement below and dive in!

How to Install Python on Windows

In that location are three installation methods on Windows:

  1. The Microsoft Shop
  2. The total installer
  3. Windows Subsystem for Linux

In this department, y'all'll larn how to check which version of Python, if any, is installed on your Windows computer. You lot'll also acquire which of the three installation methods you should utilise.

How to Check Your Python Version on Windows

To check if y'all already have Python on your Windows machine, commencement open a control-line application, such every bit PowerShell.

Yous tin also use cmd.exe or Windows Terminal.

With the command line open, type in the post-obit control and press Enter :

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

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

                                                  C:\>                  python -V                  Python 3.8.4                              

In either example, if y'all see a version less than 3.viii.4, which was the well-nigh recent version at the time of writing, then you'll want to upgrade your installation.

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

What Your Options Are

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

  1. Microsoft Shop packet: The most 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 interactive feel.

  2. Full Installer: This approach involves downloading Python directly from the Python.org website. This is recommended for intermediate and advanced developers who need more than control during the setup process.

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

In this department, we'll focus on but the commencement two options, which are the most popular installation methods in a Windows environment.

If you want to install in the WSL, then you can read the Linux department of this tutorial after you've installed the Linux distribution of your choice.

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

Limitations of the Microsoft Store Package

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

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

The key takeaway hither is that the Microsoft Store package is "intended mainly for interactive utilize." That is, the Microsoft Store parcel is designed to exist used by students and people learning to employ Python for the offset time.

In addition to targeting beginning Pythonistas, the Microsoft Store package has limitations that make it sick-suited for a professional evolution environment. In detail, it does not take full 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 building professional software, and so you should install from the Microsoft Store package. This offers the shortest and easiest path to getting started with minimal hassle.

On the other hand, if yous're an experienced programmer looking to develop professional software in a Windows surroundings, so the official Python.org installer is the correct option. Your installation won't be limited past Microsoft Store policies, and yous tin control where the executable is installed and even add together Python to PATH if necessary.

How to Install From the Microsoft Store

If yous're new to Python and looking to get started speedily, then the Microsoft Shop package is the all-time mode to get up and running without any fuss. You can install from the Microsoft Store in two steps.

Stride 1: Open up the Python App Folio in the Microsoft Shop

Open up the Microsoft Store app and search for Python.

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

The Microsoft Store search results for "Python"

Select Python 3.eight, or the highest version number y'all see available in the app, to open the installation page.

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

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

Step 2: Install the Python App

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

  1. Click Become.

  2. Wait for the application to download. When it's finished downloading, the Get button volition exist 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 kickoff the installation.

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

Congratulations! You now accept admission to Python, including pip and IDLE!

How to Install From the Full Installer

For professional person developers who need a full-featured Python evolution environment, installing from the full installer is the right selection. It offers more customization and control over the installation than installing from the Microsoft Store.

Y'all tin install from the full installer in ii steps.

Stride ane: Download the Full Installer

Follow these steps to download the full installer:

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

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

  3. Coil 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 certain whether to select the 32-chip or the 64-bit installer, then you can expand the box below to help yous decide.

For Windows, you can cull either the 32-chip or the 64-bit installer. Here's the deviation between the two:

  • If your system has a 32-flake processor, then you should cull the 32-bit installer. If y'all try to install the 64-flake version on a 32-bit processor, and then you'll become an mistake at the kickoff and the install will fail.

  • On a 64-bit system, either installer will piece of work for most purposes. The 32-bit version will generally use less retentivity, only the 64-chip version performs better for applications with intensive computation.

If y'all're unsure which version to option, become with the 64-fleck version.

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

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

Stride 2: Run the Installer

Once you've called and downloaded an installer, run it by double-clicking on the downloaded file. A dialog box like the ane below volition appear:

Windows installation dialog

There are four things to detect 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 get installed, including pip and IDLE.

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

  4. The Add Python 3.eight to PATH checkbox is unchecked by default. There are several reasons that you might not want Python on PATH, and then make certain you sympathise the implications before you check this box.

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

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

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

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 parcel director

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

How to Cheque Your Python Version on a Mac

To check which Python version you lot take on your Mac, first open a command-line application, such as Terminal.

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

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

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

For example, if Python 3.6.10 were already gear up on your reckoner, then the python3 command would brandish that version number:

                                                  $                  python3 --version                  Python 3.6.10                              
You'll desire to get the latest version of Python if any of these conditions is true:
  • None of the above commands returns a version number.
  • The only version you meet displayed is in the Python two.10 series.
  • You have a version of Python 3 that isn't the latest available, which was version iii.8.four as of this writing.

What Your Options Are

There are 2 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 package director: This method involves downloading and installing the Homebrew packet manager if you lot don't already accept it installed, and and so typing a command into a final awarding.

Both the official installer and the Homebrew parcel managing director volition work, merely only 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 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 organization version of Tcl/Tk may exist outdated or missing entirely and could prevent you from importing the Tkinter module.

macOS Installer Recommendations

The Homebrew parcel manager is a popular method for installing Python on macOS because it'southward easy to manage from the command line and offers commands to upgrade Python without having to become to a website. Considering Homebrew is a command-line utility, information technology tin be automatic with bash scripts.

However, the Python distribution offered past Homebrew isn't controlled by the Python Software Foundation and could change at any time. The almost reliable method on macOS is to use the official installer, particularly 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 tin can install from the official installer in two steps.

Step ane: Download the Official Installer

Follow these steps to download the full installer:

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

  2. Under the "Python Releases for Mac Bone X" heading, click the link for the Latest Python iii Release - Python 3.x.x. As of this writing, the latest version was Python 3.8.4.

  3. Curlicue to the lesser and click macOS 64-bit installer to start the download.

When the installer is finished downloading, motion on to the side by side footstep.

Step 2: Run the Installer

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

The macOS installation window.

Follow these steps to complete the installation:

  1. Press Go along a few times until yous're asked to hold to the software license understanding. Then click Agree.

  2. Y'all'll exist shown a window that tells y'all the install destination and how much space it will take. You most likely don't desire to change the default location, and so become ahead and click Install to starting time the installation.

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

Congratulations—you now have the latest version of Python iii on your macOS computer!

How to Install From Homebrew

For users who need to install from the control line, especially those who won't be using Python to develop graphical user interfaces with the Tkinter module, the Homebrew bundle director is a proficient option. Yous tin can install from the Homebrew package manager in two steps.

Step 1: Install Homebrew

If y'all already have Homebrew installed, and then you tin can skip this footstep. If you don't accept Homebrew installed, and then apply the following procedure to install Homebrew:

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

  2. You should meet a command for installing Homebrew almost the superlative of the folio under the tile "Install Homebrew." This command volition be something like the following:

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

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

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

  4. Enter your macOS user password when prompted.

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

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

Step 2: Install Python

Follow these steps to consummate the installation with Homebrew:

  1. Open a terminal awarding.

  2. Blazon 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 prepare upwards the latest version of Python on your motorcar.

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

  1. Open up a terminal.

  2. Blazon pip3 and press Enter .

  3. You should see the aid text from Python'southward pip bundle manager. If you get an mistake message running pip3, then get through the install steps once more to make certain you have a working installation.

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

How to Install Python on Linux

There are two installation methods on Linux:

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

In this section, you lot'll learn how to check which version of Python, if whatever, is on your Linux computer. You'll too learn which of the ii installation methods you should apply.

How to Check Your Python Version on Linux

Many Linux distributions come up packaged with Python, but it probably won't be the latest version and may even be Python 2 instead of Python 3. You should bank check the version to make certain.

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

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

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

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

                                                  $                  python3 --version                  Python iii.6.x                              

You'll desire to get the latest version of Python if your current version is in the Python 2.Ten series or is not the latest version of Python three available, which was 3.8.iv as of this writing.

What Your Options Are

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

  1. Install from a package director: This is the most common installation method on well-nigh 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. Information technology involves running a series of commands from the command line as well as making sure you have the right dependencies installed to compile the Python source lawmaking.

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

Which installation method yous employ mainly boils downward to whether your Linux OS has a package manager and whether y'all need to command the details of the installation.

Linux Installation Recommendations

The virtually popular way to install Python on Linux is with your operating system's package director, which is a practiced selection for most users. However, depending on your Linux distribution, Python may not be available through a packet director. In this example, y'all'll need to build Python from source lawmaking.

At that place are iii main reasons that you lot might cull to build Python from source lawmaking:

  1. Y'all can't download Python from your operating system'south parcel manager.

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

  3. You want to try out beta versions and release candidates of the latest and greatest version before information technology'due south generally available.

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

How to Install on Ubuntu and Linux Mint

In this department, you lot'll learn how to install Python using Ubuntu'due south apt package manager. If you lot'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 procedure for setting up Python on your system will vary. You can determine your local Ubuntu version by running the following command:

                                                  $                  lsb_release -a                  No LSB modules are available.                  Benefactor ID: Ubuntu                  Description:    Ubuntu 16.04.4 LTS                  Release:        sixteen.04                  Codename:       xenial                              

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

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

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

    Once the installation is consummate, yous can run Python 3.8 with the python3.8 command and pip with the pip3 command.

  • Linux Mint and Ubuntu 17 and below: Python three.8 isn't in the Universe repository, then you need to become it from a Personal Package Annal (PPA). For instance, to install from the "deadsnakes" PPA, employ the following commands:

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

    Once the installation is complete, you tin run Python 3.8 with the python3.8 control and run pip with the pip3 command.

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

How to Install on Debian Linux

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

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

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

                                your_username ALL=(ALL) ALL                              

At present you can 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 Python on openSUSE. To practice that, you lot'll need to install the development tools, which can be washed in YaST via the menus or by using zypper:

                                                  $                  sudu zypper install -t design devel_C_C                              

This might accept a while to complete every bit it installs over 150 packages. Once it's completed, skip alee to the How to Build Python From Source Lawmaking section.

How to Install on CentOS and Fedora

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

First, update the yum package managing director:

In one case yum finishes updating, you can install the necessary build dependencies with the post-obit commands:

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

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

How to Install on Arch Linux

Curvation Linux is fairly diligent well-nigh keeping upward with Python releases. It's probable you already have 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 Code

Sometimes your Linux distribution doesn't take the latest version of Python, or maybe you lot just want to exist able to build the latest, greatest version yourself. Here are the steps you demand to accept to build Python from source:

Step 1: Download the Source Code

To outset, you demand to go the Python source code. Python.org makes this fairly straightforward. If you go to the Downloads page, so y'all'll run into the latest source for Python 3 at the elevation. Just make sure you don't grab Legacy Python, Python 2!

When you select the Python 3 version, y'all'll encounter a "Files" section at the bottom of the folio. Select Gzipped source tarball and download information technology to your machine. If you prefer a control-line method, you can utilise wget to download the file to your current directory:

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

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

Footstep two: Gear up Your System

There are a few distro-specific steps involved in building Python from scratch. The goal of each pace is the same on all distros, but y'all might demand to translate to your distribution if it doesn't employ apt-get:

  1. Showtime, update your packet managing director and upgrade your packages:

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

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

    Information technology'south fine if you already have some of the requirements installed on your system. You tin execute the above commands and whatever existing packages will not be overwritten.

At present that your organisation is set to get, it's fourth dimension to outset building Python!

Step 3: Build Python

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

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

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

    The enable-optimizations flag will enable some optimizations inside Python to make it run about 10 percentage faster. Doing this may add twenty or thirty minutes to the compilation time. The with-ensurepip=install flag will install pip arranged with this installation.

  3. Next, y'all build Python using make. The -j choice simply tells make to divide the building into parallel steps to speed upwardly the compilation. Even with the parallel builds, this step can take several minutes:

  4. Finally, yous'll desire to install your new version of Python. You'll utilize the altinstall target here to avert overwriting the organization Python. Since y'all're installing into /usr/bin, y'all'll need to run equally root:

Information technology might take a while to end installation. Once information technology's done, you lot can verify that Python is fix correctly.

Step 4: Verify Your Installation

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

                                                        $                    python3.viii --version                    Python 3.viii.four                                  

If you encounter Python 3.viii.four, so you're all set!

If you have some extra time on your hands, you can besides run the test suite to make sure everything is working properly on your organisation.

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

Y'all'll probably desire to find something else to practise for a while, as your computer will be running tests for some time. If all the tests pass, so you 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 development environment that you tin 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 employ. Information technology'southward a great little tool when you're stuck without a laptop and want to work on your Python skills on the go. It comes with the complete Python 3 standard library and fifty-fifty includes total documentation that you tin can browse offline.

To set upward Pythonista, y'all demand to download it from the iOS app shop.

How to Install Python on Android

If yous have an Android tablet or phone and want to practice Python on the go, there are several options bachelor. The one that we plant most reliably supports Python 3.viii is Pydroid 3.

Pydroid 3 features an interpreter that you tin utilize for REPL sessions, and information technology too allows yous to edit, save, and execute Python code.

You can download and install Pydroid three from the Google Play store. At that place is a costless version and also a paid Premium version that supports lawmaking prediction and code analysis.

Online Python Interpreters

If y'all want to endeavor out the examples in this tutorial without setting upward Python on your auto, then at that place are several websites that offering an online Python interpreter:

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

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

Conclusion

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

In this tutorial you lot've learned how to:

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

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

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