Built with Tutify.io

    AIStudyLabs

    Install and Setup Python

    Install and Setup Python

    Introduction

    In this lesson, you'll transition from learning about Python to actively running Python code on your computer. You will:

    By the end of this lesson, your system will be ready for hands-on coding throughout the course.

    Installing Python on Different Operating Systems

    We prioritize official distributions to avoid broken or outdated installations.

    Windows

    1. Visit the official download page: Python for Windows
    2. Download the latest stable Python 3.x installer (64-bit).
    3. Run the installer, making sure to:
      • Check Add Python 3.x to PATH (this is crucial).
    4. Choose Customize installation if you prefer, but default options are safe.
    5. Complete the installation process.

    macOS

    macOS comes with a system Python that's often outdated and reserved for the OS. Install your own version:

    1. Visit Python for macOS
    2. Download the latest macOS 64-bit universal2 installer.
    3. Open the .pkg file and follow the installation wizard.
    4. Post-installation, Python is usually available as python3 and pip3.

    Note: You can also use Homebrew (brew install python), but we'll assume you use the official installer unless otherwise specified.

    Linux (Ubuntu / Debian-based and Others)

    Most Linux distributions include Python, but you might need development-friendly versions.

    Configuring Environment Variables and Verifying Installation

    Checking Python from the Command Line

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

    python --version
    

    If that fails (commonly on macOS/Linux), try:

    python3 --version
    

    You should see something like:

    Python 3.12.1
    

    Fixing PATH on Windows (if needed)

    If python is not recognized:

    1. Know the exact location where Python installed
    2. Press Win key, search for Environment Variables.
    3. Open Edit the system environment variables → Environment Variables….
    4. Under User variables, select Path → Edit.
    5. Add entries similar to below or you location where python installed:
      • C:\Users\<YourUser>\AppData\Local\Programs\Python\Python312\
      • C:\Users\<YourUser>\AppData\Local\Programs\Python\Python312\Scripts\
    6. Click OK on all dialogs, restart your terminal, and run python --version again.

    Running a Simple Test Script

    Create a file named test_setup.py and add:

    import sys
    
    print("Python is working!")
    print("Version:", sys.version)
    print("Executable:", sys.executable)
    

    Run it from the terminal in the folder where the file is saved:

    python test_setup.py
    

    Expected output:

    Python is working!
    Version: 3.12.1 (tags/...) 
    Executable: C:\Users\YourUser\AppData\Local\Programs\Python\Python312\python.exe
    

    This confirms Python runs correctly and shows which interpreter you are using.

    Summary / Key Takeaways

    In this lesson, you have learned how to:

    Python Programming – Complete Course with Practical Examples — Getting Started with Python and the Course

    Getting Started with Python and the Course

    Python Syntax, Indentation, and Core Concepts

    Variables, Data Types, and Type Conversion

    Operators, Expressions, and Control Flow

    Loops and Iteration Patterns

    Working with Strings in Depth

    Collections: Lists, Tuples, Sets, and Dictionaries

    Functions and Program Structuring

    Functional Programming Concepts in Python

    Modules, Packages, and Code Organization

    Error Handling and Debugging Fundamentals

    File Handling and Data Formats

    Object-Oriented Programming in Python

    Advanced Python: Iterators, Generators, and Decorators

    Python Standard Library for Real-World Tasks

    Python for Automation and Scripting

    Testing and Quality Assurance in Python

    Tutorial Not Found