How to Install Python?

This article is a complementary resource to the Learn Python Basics course.

How to Install Python?

Python is a versatile, high-level programming language that is widely supported across all major operating systems.

Let's see how you can install Python on your computer.

Install Python on Your Computer

To install Python on your Windows, just follow these steps:

  1. Install VS Code
  2. Download Python Installer File
  3. Run the Installer
  4. Install Python
  5. Verify your installation

Step 1: Install VS Code

Go to the VS Code Official website and download the Windows installer. Once the download is complete, run the installer and follow the installation process.

Click Finish to complete the installation process.

Step 2: Download the Python Installer File

Go to the official Python website and download the latest version (Python 3.13.1 at the time of writing this tutorial) for Windows.

Python Download Page
Python Download Page

Step 3: Run the Installer

Now, go to your download folder and run the installer you just downloaded. Depending on your security settings, you might be prompted to allow access. Simply allow it and proceed.

Step 4: Install Python

Once you have run the installer, you will come across this screen:

Install Python on Windows
Install Python on Windows

On the screen, you will see two options: Install Now and Customize Installation. We suggest you skip all customization steps and simply click Install Now.

  • Check on Add python.exe to PATH as it ensures Python is added to our system's PATH variable. (Recommended)
  • Click Install Now, as it will include all the necessary files needed later.

After using this option, Python will be successfully installed on your device.

Python Default Installation
Python Default Installation

Step 5: Verify your installation

After the installation is complete, you can verify whether Python is installed by using the following command in the command prompt:

python --version
Python Installation Verification for Windows
Python Installation Verification for Windows

Note: The version number might differ from the one above, depending on your installed version.

To install Python on your Mac, just follow these steps:

  1. Install VS Code
  2. Check Python version
  3. Download the Python Installer File
  4. Run the Installer
  5. Follow the Instructions
  6. Verify your installation

Step 1: Install VS Code

Go to the VS Code official website and download the zipped file. Once the download is complete, open the zipped file.

Step 2: Check Python Version

Since macOS often comes with an older version of Python (Python 2.x) pre-installed on it, you can check the current version by using the following command in the Terminal app:

python --version

or, for Python 3:

python3 --version

If you are satisfied with the installed version of Python, you can skip the remaining steps. Otherwise, follow the steps below.

Step 3: Download the Python Installer File

Visit the official Python website and download the latest version (Python 3.13.1 at the time of writing this tutorial) for macOS.

Python Download Page for Mac
Python Download Page for Mac

Step 4: Run the Installer

Go to your downloads folder and run the installer you just downloaded.

Python Run Installer for Mac
Python Run Installer for Mac

Step 5: Follow the Instructions

You will be prompted to agree to the software license agreement, choose the installation location (we recommend using the default location), and enter your administrator password. Simply proceed through it.

Step 6: Verify your installation

python3 --version
Python Installation Verification for Mac
Python Installation Verification for Mac

Note: The version number might differ from the one above, depending on your installed version.

Linux has various distributions, and the installation process differs slightly for each of them. For now, we will focus on the Ubuntu distribution.

Most Linux distributions come pre-installed with Python. However, if you need to install or upgrade, follow these steps:

  1. Install VS Code
  2. Check Python Version
  3. Install Python via Package Manager
  4. Verify your installation

Step 1: Install VS Code

Open the Terminal and type:

sudo apt update

This command updates your package lists to ensure you get the latest versions of your software.

Proceed to install VS Code with:

sudo snap install code --classic

Step 2: Check Python Version

You can check the current version of Python by using the following command in the terminal window:

python --version

or, for Python 3:

python3 --version

If you are satisfied with the installed version of Python, you can skip the remaining steps. Otherwise, follow the steps below.

Step 3: Install Python via Package Manager

Update the package list to ensure you get the latest version available:

sudo apt update

Install Python 3:

sudo apt install python3

This command installs Python along with pip (Python package installer), documentation, and other useful packages.

Python Installation for Linux
Python Installation for Linux

Wait until the installation finishes to start using Python.

Step 4: Verify your Installation

Once the installation is complete, you can verify whether Python is installed by using the following command in the terminal:

python3 --version
Python Installation Verification for Linux
Python Installation Verification for Linux

Note: The version number might differ from the one above, depending on your installed version.

Now, you are all set to run Python programs on your Linux device.

Run Your First Python Program

First, open VS Code, click on the File in the top menu, and then select New File.

Create a New File in VS Code
Create a New File in VS Code

Then, save this file with a .py extension by clicking on File again, then Save As, and type your filename ending in .py (e.g., Hello_World.py).

Before you start coding, make sure the Python extension is installed in VS Code. Open VS Code and click on Extensions on the left sidebar. Then, search for the Python extension by Microsoft and click on install.

Python Extension in VSCode
Python Extension in VSCode

Now, write the following code into your file:

print("Hello World")

Then click on the run button on the top right side of your screen.

Python Run Program
Python Run Program

You should see Hello World printed to the terminal.