PythonBeginner's Guide

Install Python on Windows, Mac, and Linux: Step-by-Step Guide

TT
TopicTrick
Install Python on Windows, Mac, and Linux: Step-by-Step Guide

Introduction to Python Installation

Installing Python is the first step in your programming journey. While it's as simple as installing any standard software, choosing the right version and configuring your system path correctly is crucial for a smooth development experience.

In this guide, we will cover how to install Python 3 across all major platforms:

  • Windows
  • Linux (Ubuntu & Building from source)
  • macOS
  • Mobile Devices (Android & iOS)

Python 2 vs Python 3

Python 2 officially reached its end of life on January 1, 2020. You should always install and use Python 3.x for any modern development.


    1. Install Python on Windows

    Unlike Linux or Mac, Windows does not come with Python pre-installed. However, the official installer makes it incredibly easy.

    Downloading the Installer

    1. Visit the official Python website: python.org/downloads.
    2. Click the large Download Python 3.x.x button. The site will automatically detect you are on Windows.

    The Installation Process

    1. Open the .exe file you just downloaded.
    2. CRITICAL STEP: At the bottom of the installation window, check the box that says "Add Python 3.x to PATH". If you miss this, Python won't easily run from your terminal!
    3. Click Install Now.
    4. Once completed, you should see a "Setup was successful" message.

    Verifying the Installation

    Open Command Prompt (cmd) and type:

    bash
    1python --version

    If it prints Python 3.x.x, you are ready to code!


    2. Install Python on Linux

    Most Linux distributions come with Python pre-installed. However, older distros might default to Python 2.

    To check your current versions, open your terminal (Ctrl + Alt + T):

    bash
    1python --version 2python3 --version

    Installing via apt (Ubuntu/Debian)

    If you need to install or upgrade to the latest Python 3 version:

    bash
    1# Update repositories 2sudo apt update 3 4# Install software properties 5sudo apt install software-properties-common 6 7# Add the official deadsnakes PPA (contains newer Python versions) 8sudo add-apt-repository ppa:deadsnakes/ppa 9 10# Install Python 3 11sudo apt install python3

    Setting Python 3 as Default

    If typing python still runs Python 2, you can create an alias in your bash profile.

    bash
    1# Open your bashrc file 2nano ~/.bashrc 3 4# Add this line to the very bottom 5alias python=python3 6 7# Save, exit, and reload the profile 8source ~/.bashrc

    3. Install Python on macOS

    macOS historically shipped with Python 2.7 (though newer versions have removed it). You'll need to install the latest Python 3 release.

    Downloading the Installer

    1. Visit python.org/downloads/mac-osx/.
    2. Download the macOS 64-bit universal2 installer for the latest Python 3 release.
    3. Run the .pkg file and follow the standard installation wizard.

    Verifying on Mac

    Open your Terminal and type:

    bash
    1python3 --version

    Using Homebrew

    If you are a developer using Mac, the preferred way to install Python is via [Homebrew](https://brew.sh/). Simply run `brew install python` in your terminal.


      4. Coding Python on Mobile

      Yes, you can write and run Python scripts directly from your smartphone!

      Python on Android

      Search the Google Play Store for Pydroid 3 - IDE for Python 3. It provides an excellent offline Linux environment where you can even use libraries like Pandas, NumPy, and Matplotlib.

      Python on iOS (iPhone/iPad)

      Search the Apple App Store for Pythonista 3 or Pyto. Both provide robust environments for coding Python on the go.


      Conclusion

      You are now equipped to run Python on any device! Whether you rely on Windows, develop on a Mac, run Linux servers, or just want to practice coding on the train via your phone—Python is everywhere.

      Your next step is to choose a good Code Editor (like VS Code or PyCharm) and start writing your first scripts!