Harness the Combinatoric Power of Command-Line Tools and Utilities

../Tutorials

Install Python on macOS, Windows, and Linux

programming languages Python WSL Homebrew

Published April 28, 2024

Python is a popular programming language known for its simplicity and versatility. It supports multiple programming paradigms and is widely used in web development, data analysis, artificial intelligence, scientific computing, and more.

Command line tools written in Python require Python to be installed on the system to function. In this tutorial, you’ll install Python on your system so you can use it to run command line tools.

What You Need

  • On macOS, you’ll need Homebrew installed, which you can do by following the Install Homebrew tutorial.
  • On Windows, if you want to use the Linux version of Python, you’ll need WSL installed, which you can do by following the Install WSL tutorial.

Install Python on macOS

Install Python on macOS using Homebrew with the following command:

brew install python

This command installs Python along with pip, Python’s package manager, which you can use to install other Python packages.

Install Python on Ubuntu

To install Python on Ubuntu, you’ll use the apt package manager. Ubuntu comes with Python pre-installed, but you can ensure you have the latest version by running the following commands:

First, update your package list:

sudo apt update

Install Python with:

sudo apt install -y python3

This command also installs pip3, the Python package manager, allowing you to manage additional Python libraries.

Install Python on Windows

You can install Python either from the Windows Store or use it under the Windows Subsystem for Linux (WSL) for better manageability and integration.

To install from the Windows Store:

  1. Open the Microsoft Store app on your Windows machine.
  2. Search for “Python” in the top-right search bar.
  3. Select the latest version of Python (e.g., Python 3.10) offered by the Python Software Foundation.
  4. Click the “Get” button to download and install Python.

This method ensures that Python is kept up to date automatically and is installed on your PATH.

If you’re developing in a Linux-like environment, you might prefer to use Python under WSL.

Assuming you installed WSL by following the Install WSL tutorial, open your new WSL session.

From the terminal, Update your package list:

sudo apt update

Now install Python:

sudo apt install -y python3

This installs Python along with pip3, allowing you to manage additional Python packages in a Linux environment on your Windows system.

Conclusion

With Python installed, you can now use it to execute a variety of powerful command-line tools written in Python. Whether you’re automating tasks, managing data, or developing applications, Python provides a robust foundation for your scripting needs.