Installing Python & IDE Setup

Module 1 • Session 02 • Allocation: 1 Contact Hr

CPython PATH Variable VS Code PyCharm

Before writing software, you need the **Python Interpreter** (CPython) installed on your operating system and a development environment (IDE or code editor) configured for code execution, linting, and debugging.

1. Downloading and Installing CPython

Official installers are available at python.org/downloads.

Windows Installation Steps

  1. Download the Windows installer (64-bit).
  2. Launch the .exe installer.
  3. CRITICAL STEP: Check the box labeled Add python.exe to PATH at the bottom of the installer window.
  4. Click Install Now.
Why checking "Add to PATH" matters: Adding Python to system environment variables allows your Command Prompt, PowerShell, or terminal to recognize commands like python and pip from any working directory.

macOS Installation Steps

macOS comes with system utilities, but you should install official modern Python releases via the official macOS package or Homebrew:

# Using Homebrew package manager on macOS: brew install python # Verify installation directory: which python3 # Output: /opt/homebrew/bin/python3 (Apple Silicon) or /usr/local/bin/python3 (Intel)

Linux (Ubuntu/Debian) Installation Steps

Linux distributions typically ship with Python 3 pre-installed. You can update or install development tools using apt:

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

2. Verifying Installation & Environment Path

Open your system terminal (Command Prompt, PowerShell, or bash/zsh terminal) and verify that the Python interpreter and package manager (pip) are configured correctly:

# Command Prompt / Terminal verification: python --version # or python3 --version pip --version # or pip3 --version # Checking active binary location: # On Windows PowerShell: Get-Command python | Select-Object -ExpandProperty Definition # On Linux/macOS: which python3

3. Selecting and Configuring an IDE

While you can write Python code in a basic text editor and run it from the command line, an **Integrated Development Environment (IDE)** offers features like syntax highlighting, auto-completion (IntelliSense), inline error detection, and built-in debugging tools.

IDE / Editor Best Used For Key Advantage
VS Code General Software, Web Dev, Scripts Lightweight, vast extension ecosystem
PyCharm Large OOP Applications, Enterprise Deep refactoring, built-in database support
Jupyter Notebook Data Science, Machine Learning, Analytics Interactive block execution with visual charts

Setting Up Visual Studio Code (VS Code)

  1. Download and install Visual Studio Code from code.visualstudio.com.
  2. Open VS Code and navigate to the Extensions Marketplace (Ctrl+Shift+X / Cmd+Shift+X).
  3. Search for and install the official Python Extension by Microsoft.
  4. Select your Python interpreter by pressing Ctrl+Shift+P (Cmd+Shift+P), typing Python: Select Interpreter, and picking your installed version.

4. Writing Your First Script & Programmatic Environment Inspection

You can inspect details about your Python runtime dynamically using the sys and platform built-in modules:

import sys import platform print(f"Python Version: {platform.python_version()}") print(f"Executable Path: {sys.executable}") print(f"Operating System: {platform.system()} {platform.release()}") print(f"Architecture: {platform.machine()}")

šŸ‹ļø Try It Yourself: Practice Challenges

Challenge 1: System Environment Audit

Run the interactive sandbox below using sys and platform to extract details about your Python build, platform architecture, and execution flags.

Challenge 2: Verify Import Paths

Write a script to iterate over sys.path and print each directory where Python searches for imported modules.

Challenge 3: Version Qualifier Check

Use sys.version_info to check if the current environment is running Python version 3.8 or higher, and print a confirmation message.

⚔ Interactive Sandbox (Inspect Runtime Environment)
Console Output:
Click "Run Code" above to execute interactive input scripts...

šŸ“ Knowledge Check Quiz

1. Why is checking "Add python.exe to PATH" crucial during Windows setup?
2. Which Python module contains sys.executable and sys.path for checking execution context?
3. Which tool is best suited for interactive data analysis with visual block execution?
Advertisement
Horizontal Ad Banner Slot (728x90 / Responsive)