Home Blogs All Courses
python c OA ( Online Assessment ) Amazon Web Services (AWS) leetcode dsa algorithms java Machine learning
Get Referral
Login Sign Up

python › Python Installation

How to Install Python on Windows, Ubuntu & macOS (Step-by-Step Guide)

phoolchandra  ·  Oct 23, 2026  · Published


Before you can write Python programs, you need Python installed on your computer. The good news: it is free and takes less than 5 minutes. In this step-by-step guide you will install Python on Windows, Ubuntu (Linux) and macOS, verify the installation, choose a code editor, run your first program and fix the most common installation errors.

Watch the video first, then use this blog as your notes. Every section has runnable examples, and at the end you will find a "Predict the Output" quiz, practice challenges, a self-check list, interview questions and a quick summary.

How to use this blog: Open the Python shell (type python in your terminal) or any online Python editor and type every example yourself. Change the values, break the code and see what happens — that is how concepts really stick.

1. Step 0 — Check if Python is Already Installed

Open a terminal (Command Prompt / PowerShell on Windows, Terminal on macOS and Linux) and type:

python --version
# or
python3 --version

If you see something like Python 3.x.y, Python 3 is already installed. If you see an error, or Python 2.7, follow the steps below.

Which version should I install?: Always install the latest stable Python 3 release from python.org. Never install Python 2 — it reached end-of-life in 2020.

2. Installing Python on Windows

  1. Go to python.org/downloads and click Download Python 3.x.
  2. Open the downloaded .exe installer.
  3. Tick the checkbox "Add python.exe to PATH" at the bottom of the first screen. This is the most important step!
  4. Click Install Now and wait for it to finish.
  5. Click "Disable path length limit" if shown (recommended), then Close.

Verify the installation: open a new Command Prompt and run:

python --version
pip --version
py --version        # the Windows Python launcher

Why "Add to PATH" matters: PATH is a list of folders where your computer looks for programs. If Python is not in PATH, typing python gives the error "python is not recognized as an internal or external command".

3. Installing Python on Ubuntu / Linux

Most Ubuntu versions already include Python 3. Check with python3 --version. To install or update it along with pip and virtual environment support:

sudo apt update
sudo apt install python3 python3-pip python3-venv -y

# verify
python3 --version
pip3 --version

Important for Linux users: On Ubuntu, the command is python3 (not python). Do not remove or replace the system Python — Ubuntu itself depends on it. Use virtual environments for your projects instead.

4. Installing Python on macOS

Option A — Official installer (easiest)

  1. Download the macOS installer (.pkg) from python.org/downloads.
  2. Open it and follow the steps: Continue → Agree → Install.
  3. At the end, double-click "Install Certificates.command" in the Python folder inside Applications.

Option B — Homebrew (preferred by developers)

# install Homebrew first if you don't have it: https://brew.sh
brew install python

# verify
python3 --version
pip3 --version

On macOS, use python3 and pip3 commands.

5. Quick Comparison of Commands

TaskWindowsUbuntu / macOS
Check versionpython --versionpython3 --version
Start Python shellpython or pypython3
Run a filepython hello.pypython3 hello.py
Install a packagepip install requestspip3 install requests
Exit the shellexit() or Ctrl + Z, Enterexit() or Ctrl + D

6. Run Your First Python Program

Method 1 — The interactive shell (REPL)

$ python3
>>> print("Hello, Coding Battle!")
Hello, Coding Battle!
>>> 7 * 6
42
>>> exit()

Method 2 — A Python file (script mode)

  1. Create a file named hello.py.
  2. Write the code below and save it.
  3. Open the terminal in the same folder and run python hello.py (or python3 hello.py).
# hello.py
name = input("What is your name? ")
print("Hello,", name, "- welcome to Python!")
What is your name? Riya
Hello, Riya - welcome to Python!

7. Choosing a Code Editor / IDE

EditorBest forNotes
IDLEAbsolute beginnersComes with Python on Windows and macOS
VS CodeMost learners and professionalsFree, lightweight; install the official Python extension by Microsoft
PyCharm (Community)Large projectsPowerful, heavier; great debugging tools
Jupyter NotebookData science and MLRun code cell by cell with charts inline: pip install notebook
Google ColabNo installation at allRuns in the browser, free GPU for ML

Recommendation: Start with VS Code + Python extension. It is what most developers use daily and it grows with you from beginner to professional.

8. pip — Installing Extra Packages

pip is Python's package manager. It downloads libraries from PyPI (the Python Package Index).

pip install requests        # install a package
pip list                    # see installed packages
pip show requests           # details of a package
pip uninstall requests      # remove a package
python -m pip install --upgrade pip   # upgrade pip itself

9. Pro Tip: Virtual Environments

A virtual environment is an isolated folder with its own Python and packages for one project. Project A can use Django 4 while Project B uses Django 5 — no conflicts.

# create (inside your project folder)
python -m venv venv           # Windows
python3 -m venv venv          # macOS / Linux

# activate
venv\Scripts\activate         # Windows
source venv/bin/activate      # macOS / Linux

# now install packages only for this project
pip install django

# leave the environment
deactivate

10. Common Installation Problems and Fixes

ProblemCauseFix
"python is not recognized as an internal or external command"Python not added to PATHRe-run the installer → Modify → tick "Add Python to environment variables", or reinstall with "Add python.exe to PATH" ticked. Open a new terminal.
Typing python opens the Microsoft StoreWindows "App execution aliases"Settings → Apps → Advanced app settings → App execution aliases → turn off the python.exe and python3.exe aliases
python: command not found on Linux/macOSThe command is named python3Use python3 instead
pip: command not foundpip not in PATH or not installedUse python -m pip install ... or install python3-pip
"externally-managed-environment" error on UbuntuProtects the system PythonCreate a virtual environment and install packages inside it
Old version still shows after installingMultiple Pythons installedOn Windows use py -0 to list versions; on macOS/Linux use which python3

Quiz: Predict the Output

Don't run the code yet! Write your answers in a notebook, then check the Answers section at the end of this blog.

Q1. Which checkbox is the most important during Windows installation?

Q2. On Ubuntu, which command checks the Python version?

Q3. What is the output when you type this in the Python shell?

>>> 7 * 6

Q4. What is pip?

Q5. What is the output of this program if the user types Aman?

name = input("Name: ")
print("Hi", name)

Q6. Which command creates a virtual environment called venv?

Q7. True or False: You should delete the system Python on Ubuntu and install a new one.

Practice Challenges

Solve these from easy to tricky:

  1. Install Python on your computer and take a screenshot of python --version.
  2. Open the Python shell and calculate 365 × 24 (the hours in a year).
  3. Create a file about_me.py that prints your name, class and favourite subject. Run it from the terminal.
  4. Install VS Code and the Python extension, then run about_me.py using the ▶ Run button.
  5. Create a virtual environment, activate it, install the requests package, and run pip list.

A sample solution for challenge 3 is in the Answers section.

Self-Check: Can You Do This?

Tick off each skill once you are confident:

Frequently Asked Interview Questions

Q: What is the difference between python and python3 commands?
On Windows the installer creates python. On macOS and Linux, python may not exist or may point to an old Python 2, so python3 is used to run Python 3.

Q: What is PATH?
An environment variable listing folders in which the OS searches for executable programs.

Q: What is PyPI?
The Python Package Index — the official online repository of third-party Python packages, used by pip.

Q: Why use a virtual environment?
To isolate each project's dependencies so different projects can use different package versions without conflicts.

Q: What is IDLE?
Python's built-in simple editor and shell (Integrated Development and Learning Environment).

Summary

  • Download Python 3 from python.org. On Windows, tick "Add python.exe to PATH".
  • Ubuntu: sudo apt install python3 python3-pip python3-venv. macOS: python.org installer or brew install python.
  • Verify with python --version / python3 --version.
  • Run code in the shell or as a .py file.
  • Use pip to install packages and venv to isolate projects.
  • Recommended editor for beginners: VS Code + Python extension.

Quick Revision Cheat Sheet

ConceptSyntax / Key point
Check versionpython --version
Run a filepython hello.py
Install packagepip install name
Create venvpython -m venv venv
Activate (Windows)venv\Scripts\activate
Activate (Mac/Linux)source venv/bin/activate

Answers

Quiz answers

  1. "Add python.exe to PATH".
  2. python3 --version
  3. 42
  4. Python's package manager — it installs libraries from PyPI.
  5. Hi Aman
  6. python -m venv venv (or python3 -m venv venv).
  7. False – Ubuntu needs its system Python. Use virtual environments.

Challenge solutions

# Challenge 3: about_me.py
print("Name: Riya")
print("Class: 11")
print("Favourite subject: Mathematics")

# Run it from the terminal:
#   python about_me.py      (Windows)
#   python3 about_me.py     (macOS / Linux)

Conclusion

Python is now installed and you have run your first program. Next, learn the print() function in detail to control exactly how your program displays output.

If this blog helped you, watch the full video above, subscribe to the channel and share it with a friend who is learning Python. Happy coding!