0

How to Install Python on Ubuntu, Mac, and Windows: Complete Guide


Python is one of the most popular programming languages in the world, prized for its simplicity and power. Whether you want into get into web development, data science, or automation, the first step is to install Python on your machine.

This guide explains how to install Python 3 on Windows, macOS, and Ubuntu (Linux).

1. Install Python on Windows

Installation on Windows has become very simple thanks to the official installer.

Python Installation on Windows

  1. Go to the official website: python.org/downloads.
  2. Click the yellow Download Python 3.x.x button (the latest stable version).
  3. Once the .exe file is downloaded, double-click it to start the installation.
  4. IMPORTANT: Check the box “Add Python.exe to PATH” at the bottom of the window. This will allow you to use the python command from anywhere in your terminal.
  5. Click Install Now.

To verify the installation, open the Command Prompt (type cmd in the Start menu) and enter:

python --version

If you see a version displayed (e.g., Python 3.12.0), you’re all set!

2. Install Python on macOS

Macs often come with a pre-installed version of Python, but it is usually an older version or one used by the system. It is recommended to install a recent version for your development needs.

Option A: Via the Official Installer (Easiest)

  1. Go to python.org/downloads/macos.
  2. Download the macOS 64-bit universal2 installer.
  3. Open the .pkg file and follow the on-screen instructions.

If you already use Homebrew, this is the ideal method for managing your packages.

Python Installation on Mac with Homebrew

Open your terminal and type:

brew install python

Then verify the installation with:

python3 --version

3. Install Python on Ubuntu (Linux)

Most Linux distributions, including Ubuntu, have Python 3 pre-installed. To check, open a terminal and type:

python3 --version

If Python is not installed or if you want a specific version, use the apt package manager.

Python Installation on Ubuntu

  1. Update the package list:
    sudo apt update
  2. Install Python 3:
    sudo apt install python3
  3. (Optional) Install pip, the Python package manager:
    sudo apt install python3-pip

Conclusion

You now have Python installed on your machine! The next step? Writing your first script. Create a file named hello.py with the following content:

print("Hello, world!")

And run it from your terminal:

python hello.py
# or python3 hello.py on Mac/Linux

Happy coding!

Comments