Which Python Version to Install?
Always install the latest stable Python 3.x release. At the time of writing, that's Python 3.12+. Never install Python 2 β it's been retired since January 2020 and is no longer supported.
Python 3.10 introduced match-case (pattern matching). Python 3.11 made error messages much clearer. Python 3.12 is faster and has better type hints. Any version 3.10+ is excellent for learning.
Installing Python on Windows
Windows doesn't come with Python pre-installed, so you need to download and install it manually. Follow these steps carefully:
-
Go to the official Python website
Visit python.org/downloads. The site automatically detects you're on Windows and shows the latest release button. -
Download the installer
Click "Download Python 3.x.x" (the big yellow button). This downloads a.exeinstaller file. -
Run the installer β CRITICAL: Check "Add Python to PATH"
Double-click the downloaded file. At the bottom of the installer, you'll see a checkbox: "Add Python 3.x to PATH". Check this box before clicking Install Now. This step is essential β without it, you can't run Python from the command line. -
Click "Install Now"
The installer sets up Python, pip (package manager), and IDLE (Python's built-in editor). The installation takes 1-2 minutes. -
Verify the installation
Open Command Prompt (press Win+R, typecmd, press Enter) and type:
python --version
Some Windows systems have a Python stub that opens the Store. Fix: Search "Manage app execution aliases" in Windows Settings and turn off the Python aliases. Then restart Command Prompt.
Installing Python on macOS
macOS may come with Python 2.7 pre-installed (on older systems), but you need Python 3. There are two recommended approaches:
Option 1: Official Installer (Recommended for Beginners)
- Go to python.org/downloads and click the macOS download link.
- Download the
.pkginstaller (choose the macOS 64-bit universal2 installer). - Double-click the .pkg file and follow the installation wizard.
- Verify in Terminal (Applications β Utilities β Terminal):
python3 --version
# Output: Python 3.12.2
On macOS, python may still point to the old Python 2. Always use python3 and pip3 on Mac to ensure you're using Python 3.
Option 2: Homebrew (Recommended for Developers)
# Install Homebrew first (if not installed)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Then install Python
brew install python
# Verify
python3 --version
Installing Python on Linux
Most Linux distributions come with Python 3 pre-installed. Check first:
python3 --version
If Python 3 is not installed or you need a newer version:
# Ubuntu/Debian
sudo apt update
sudo apt install python3 python3-pip
# Fedora/RHEL
sudo dnf install python3 python3-pip
# Arch Linux
sudo pacman -S python python-pip
Understanding pip β Python's Package Manager
Python comes with pip (Pip Installs Packages), a tool to install third-party libraries. You'll use it constantly as a Python developer.
# Check pip version
pip --version # Windows
pip3 --version # macOS/Linux
# Install a package (example: requests library)
pip install requests
# Install a specific version
pip install requests==2.31.0
# List installed packages
pip list
# Uninstall a package
pip uninstall requests
Choosing a Code Editor (IDE)
You write Python code in a text editor or IDE (Integrated Development Environment). Here are the best options:
| Editor | Best For | Cost | Difficulty |
|---|---|---|---|
| VS Code | General purpose, all skill levels | Free | Easy |
| PyCharm Community | Python-specific, powerful features | Free | Moderate |
| IDLE | Absolute beginners, comes with Python | Free | Very Easy |
| Jupyter Notebook | Data science, interactive coding | Free | Easy |
| Sublime Text | Fast, lightweight editing | Free/Paid | Easy |
Setting Up VS Code for Python (Recommended)
- Download VS Code from code.visualstudio.com
- Open VS Code and press Ctrl+Shift+X (or Cmd+Shift+X on Mac) to open Extensions
- Search for "Python" by Microsoft and click Install
- Press Ctrl+Shift+P and type "Python: Select Interpreter" to choose your Python installation
- Create a new file with a
.pyextension and start coding!
Testing Your Installation
Let's confirm everything works by running a simple Python script:
import sys
print("Python is working!")
print(f"Version: {sys.version}")
print(f"Installation: {sys.executable}")
# Quick test
numbers = [1, 2, 3, 4, 5]
print(f"Sum of {numbers} = {sum(numbers)}")
Save this as test.py and run it:
python test.py # Windows
python3 test.py # macOS/Linux
The Interactive Python Shell (REPL)
Python has an interactive shell where you can type code and see results instantly β great for experimenting:
python # Windows
python3 # macOS/Linux
>>> print("Hello!")
Hello!
>>> 2 + 2
4
>>> name = "Alice"
>>> f"Hello, {name}!"
'Hello, Alice!'
>>> exit() # To quit the REPL
ποΈ Practical Exercise
- Install Python on your computer following the steps for your operating system.
- Open Terminal/Command Prompt and verify with
python --version. - Open the interactive shell and compute:
100 * 3.14 - Create a
hello.pyfile that prints your name and favorite number, then run it. - Install the
requestslibrary using pip.
π₯ Challenge Exercise
Install VS Code, add the Python extension, and create a project folder. Write a Python script that prints a 5Γ5 multiplication table. Run it from the VS Code terminal.
Interview Questions on Python Setup
- What is pip and what is it used for?
- How do you check which version of Python is installed?
- What is the difference between Python 2 and Python 3?
- What does "Add to PATH" mean and why is it important?
- What is a virtual environment and why should you use one?
- What is IDLE? What is the difference between IDLE and VS Code?
π Summary
- Always install Python 3.10+ β never Python 2.
- On Windows: download from python.org, check "Add to PATH" during install.
- On macOS: use the official installer or Homebrew; use
python3command. - On Linux: use your package manager (
apt,dnf,pacman). - pip is Python's package manager β use it to install third-party libraries.
- VS Code with the Python extension is the recommended editor for beginners.
- The Python REPL (
python3in terminal) is great for quick experimentation.
Related Topics
Frequently Asked Questions
Yes. Tools like pyenv (Mac/Linux) or Python Launcher (Windows) let you manage multiple Python versions. You can specify which version to use per project. Virtual environments (venv) help isolate project dependencies.
Anaconda is a Python distribution bundled with 250+ data science packages. It's ideal if you're doing data science from day one. For general Python learning, start with the official Python distribution β it's lighter and teaches you to manage packages yourself.
A virtual environment isolates project dependencies so different projects don't conflict. You don't need one immediately as a beginner, but it's good practice to use them for any real project. We cover this in the Virtual Environments lesson.