Python is a versatile, high-level programming language that is widely supported across all major operating systems.
You can run Python on your computer using the following two methods:
In this tutorial, you will learn both methods.
Run Python OnlineTo execute Python code, you need to have a Python interpreter installed on your system. However, if you want to start immediately, you can use our free online Python editor.
Online Python EditorThe online editor enables you to run Python code directly in your browser—no installation required.
Install Python on Your ComputerFor those who prefer to install Python on your computer, this guide will walk you through the installation process on Windows, macOS, and Linux (Ubuntu).
To install Python on your Windows, just follow these steps:
Here is a detailed explanation of each of the steps:
Step 1: Install VS CodeGo 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 FileGo to the official Python website and download the latest version (Python 3.12.2 at the time of writing this tutorial) for Windows.
The website automatically detects your operating system and gives you the right installer.
Python Download Page Step 3: Run the InstallerNow, 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 PythonOnce you have run the installer, you will come across this screen.
Install Python on WindowsOn the screen, you will see two options: Install Now and Customize Installation. We suggest you skip all customization steps and simply click Install Now.
This makes it easier to run a Python Program from the command prompt (cmd) directly without specifying the full path of the Python executable.
After using this option, Python will be successfully installed in your device.
Python Default Installation Step 4: Verify your installationAfter the installation is complete, you can verify whether Python is installed by using the following command in the command prompt.
python --version
Python Installation Verify
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 device.
To install Python on your Mac, just follow these steps:
Here is a detailed explanation of each of the steps:
Step 1: Install VS CodeGo to the VS Code official website and download the zipped file. Once the download is complete, open the zipped file.
In Finder, open a new window and navigate to the Applications folder. Drag the VS Code application from the zip file into the Applications folder to install it.
You can now launch VS Code directly from the Applications folder.
Step 2: Check Python VersionSince 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 3.x, you can skip the remaining steps. Otherwise, follow the steps below.
Step 3: Download the Python Installer FileVisit the official Python website and download the latest version (Python 3.12.2 at the time of writing this tutorial) for mac.
The website automatically detects your operating system and gives you the right installer.
Python Download Page for Mac Step 4: Run the InstallerGo to your downloads folder and run the installer you just downloaded.
Python Run Installer for Mac Step 5: Follow the InstructionsYou will be prompted to agree to the software license agreement, choose the installation location (we recommend using default location), and enter your administrator password.
Simply proceed through it.
Step 6: Verify your installationOnce the installation is complete, you can verify whether Python is installed by using the following command in the Terminal app.
python3 --version
Python Installation Verify 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 from each other. For now, we will focus on Ubuntu distribution.
Most Linux distributions come pre-installed with Python. However, if you need to install or upgrade follow these steps:
Here is a detailed explanation of each of the steps:
Step 1: Install VS CodeOpen 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 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 ManagerUpdate 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 pip (Python package installer), documentation, and other useful packages.
Python Installation for LinuxWait until the installation finishes to start using Python.
Step 4: Verify your InstallationOnce the installation is complete, you can verify whether Python is installed by using the following command in the Terminal app.
python3 --version
Python Installation Verification for Linux
Now, you are all set to run Python programs on your device.
Run Your First Python ProgramFirst open VS Code, click on the File in the top menu and then select New File.
Create a New File in VS CodeThen, save this file with a .py extension by clicking on File again, then Save As, and type your filename ending in .py. (Here, we are saving it as 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.
Install Python Extension in VS CodeNow, 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 ProgramYou should see Hello World printed to the command prompt.
Note: Type python3 in command prompt for macOS and Linux.
Now that you have set everything up to run Python programs on your computer, you'll be learning how the basic program works in Python in the next tutorial.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4