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.
Open a terminal (Command Prompt / PowerShell on Windows, Terminal on macOS and Linux) and type:
python --version
# or
python3 --versionIf 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.
Verify the installation: open a new Command Prompt and run:
python --version
pip --version
py --version # the Windows Python launcherWhy "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".
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 --versionImportant 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.
# install Homebrew first if you don't have it: https://brew.sh
brew install python
# verify
python3 --version
pip3 --versionOn macOS, use python3 and pip3 commands.
| Task | Windows | Ubuntu / macOS |
|---|---|---|
| Check version | python --version | python3 --version |
| Start Python shell | python or py | python3 |
| Run a file | python hello.py | python3 hello.py |
| Install a package | pip install requests | pip3 install requests |
| Exit the shell | exit() or Ctrl + Z, Enter | exit() or Ctrl + D |
$ python3
>>> print("Hello, Coding Battle!")
Hello, Coding Battle!
>>> 7 * 6
42
>>> exit()# hello.py
name = input("What is your name? ")
print("Hello,", name, "- welcome to Python!")What is your name? Riya
Hello, Riya - welcome to Python!| Editor | Best for | Notes |
|---|---|---|
| IDLE | Absolute beginners | Comes with Python on Windows and macOS |
| VS Code | Most learners and professionals | Free, lightweight; install the official Python extension by Microsoft |
| PyCharm (Community) | Large projects | Powerful, heavier; great debugging tools |
| Jupyter Notebook | Data science and ML | Run code cell by cell with charts inline: pip install notebook |
| Google Colab | No installation at all | Runs 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.
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 itselfA 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| Problem | Cause | Fix |
|---|---|---|
| "python is not recognized as an internal or external command" | Python not added to PATH | Re-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 Store | Windows "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/macOS | The command is named python3 | Use python3 instead |
| pip: command not found | pip not in PATH or not installed | Use python -m pip install ... or install python3-pip |
| "externally-managed-environment" error on Ubuntu | Protects the system Python | Create a virtual environment and install packages inside it |
| Old version still shows after installing | Multiple Pythons installed | On Windows use py -0 to list versions; on macOS/Linux use which python3 |
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 * 6Q4. 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.
Solve these from easy to tricky:
A sample solution for challenge 3 is in the Answers section.
Tick off each skill once you are confident:
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).
| Concept | Syntax / Key point |
|---|---|
| Check version | python --version |
| Run a file | python hello.py |
| Install package | pip install name |
| Create venv | python -m venv venv |
| Activate (Windows) | venv\Scripts\activate |
| Activate (Mac/Linux) | source venv/bin/activate |
# 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)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!