In the previous chapter we have seen the introduction to python programming, In this tutorial we will see how to install and setup python on our machines.
As python is interpreted programming language, so in order to run our programs written in python we need to install the python interpreter. It reads the python code that we write and translates it into instructions that the computer can execute.
It is like a middleman which converts our human readable code to machine readable instructions.
I’ve provided python installation instructions for multiple Operating System, so follow the instructions carefully based on your operating system.
Note: If you have python installed on your machine you can skip this tutorial but don’t try to install python again if installed as it can cause conflicts.
Steps To Install Python On Windows OS
Go to Python Downloads page or search python downloads and visit the first link, the python downloads page will look like below:
Click the yellow download python button, It will download the latest python version which is 3.12 as of now, at the time of you reading the article it can change but make sure you download the latest one.
It will download a executable file of around 25MB, after the download is finished click on the executable file and it start the python installer with first screen looking like below.
Make sure Use admin privileges and Add python.exe to PATH is checked and click on Install Now.
A User Account Control popup will appear asking you to allow python to make changes, make sure you click on Yes and allow it.
It will start installing python and after installed it will show the below screen saying setup was successful.
You can now close the setup as python installed on your windows machine, to verify if python is installed go here: Verifying Python Installation.
Steps To Install Python On Mac OS
To install python on Mac OS it is similar to windows, Go to Python Downloads page, You will see a yellow dowload python button under “download the latest version for mac” heading,
Click on the yellow download button and it will download python installer for mac os.
After downloading run the installer and it will open the python setup, keep clicking on continue and complete the setup.
This will install python on your mac os, to check if python is installed go here: Verifying Python Installation.
Steps To Install Python On Linux
Open a terminal, type the below command, it will download and install on your linux system.
sudo apt install python3
After installing python we need to seperately install pip which is a package manager, it is essential to install use below command:
sudo apt install python3-pip
This will install python and pip on your linux machine, you can verify your installation using the below steps.
Verifying Python Installation
To verify whether python is installed on your machine, Open command prompt or teminal and type below command accordingly
For Checking In Windows
For Checking In Mac & Linux
If python installed successfully you will see the below output with installed python version:
You can also write and run your first python program in the terminal itself, type python or python3 in terminal, It will start the python interpreter in cmd, You can write print(“hello world”) and hit enter, It will print hello world.
Python 3.11.2 (tags/v3.11.2:878ead1, Feb 7 2023, 16:38:35) [MSC v.1934 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> print("hello world")
This is most basic python program to print hello world and also we will not write & run our python program in a terminal as it is not recommended and not convinient instead we will use a code editor which will see in the upcoming tutorials.
Well, I have shown you how to install python, I hope you were able to follow along and successfully install python on your system.