How to Install Python?
This article is a complementary resource to the Learn Python Basics course.
This article is a complementary resource to the Learn Python Basics course.
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.
To install Python on your Windows, just follow these steps:
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.
Go to the official Python website and download the latest version (Python 3.13.1 at the time of writing this tutorial) for Windows.
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.
Once you have run the installer, you will come across this screen:
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.
After using this option, Python will be successfully installed on your device.
After the installation is complete, you can verify whether Python is installed by using the following command in the command prompt:
python --version
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:
Go to the VS Code official website and download the zipped file. Once the download is complete, open the zipped file.
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.
Visit the official Python website and download the latest version (Python 3.13.1 at the time of writing this tutorial) for macOS.
Go to your downloads folder and run the installer you just downloaded.
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.
python3 --version
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:
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
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.
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.
Wait until the installation finishes to start using Python.
Once the installation is complete, you can verify whether Python is installed by using the following command in the terminal:
python3 --version
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.
First, open VS Code, click on the File in the top menu, and then select New File.
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.
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.
You should see Hello World printed to the terminal.