Skip to content

[2024 Update] How to Install Python on Windows, Mac, Linux

Setting up your Python programming environment is the initial step toward becoming proficient in Python programming. This process can involve various methods, including downloading the official Python distributions from Python.org, using a package manager, or opting for specialized distributions tailored to specific fields such as scientific computing, the Internet of Things, and embedded systems.

This guide focuses on the official distributions recommended for beginners who are just starting their journey in Python programming.

In this guide, you will learn how to:

  • Verify if Python is already installed on your machine and identify the installed version
  • Install or update Python on different operating systems, including Windows, macOS, and Linux
  • Utilize Python on mobile devices such as smartphones or tablets
  • Engage with Python through web-based interpreters

This comprehensive tutorial ensures that no matter your operating system, you will have the necessary information to start your Python programming journey.

Bonus Resource: Access a Python Cheat Sheet to familiarize yourself with the essentials of Python 3, including how to work with data types, dictionaries, lists, and functions.

Interactive Quiz: Test your knowledge with our “Python Installation and Setup” quiz and track your learning progress by receiving a score upon completion.

How to Install Python on Windows

Windows users have three primary methods for installing Python:

  1. Via the Microsoft Store
  2. Using the full installer available on Python.org
  3. Through the Windows Subsystem for Linux (WSL)

Checking Your Python Version on Windows

To determine if Python is already installed on your Windows machine and to identify the version, follow these steps:

  1. Open PowerShell:

    • Press the Win key, type PowerShell, and press Enter. Alternatively, right-click the Start button and select Windows PowerShell or Windows PowerShell (Admin).
  2. Check the Python Version: Enter the following command:

    Terminal window
    python --version

    Or use the -V switch for a quicker version check:

    Terminal window
    python -V

If the version displayed is older than Python 3.8.4 (the latest version at the time of writing this tutorial), an update to your Python installation is recommended.

Note: If Python isn’t installed, executing the above commands will prompt the Microsoft Store to open, directing you to the Python application page for installation.

Installation Options on Windows

As previously mentioned, there are three main ways to install Python on Windows. Each method serves different user needs:

  • Microsoft Store package: This method is straightforward and recommended for beginners for its ease of setup.

  • Full Installer: Downloading directly from Python.org provides more control during the setup process, suitable for intermediate and advanced users.

  • Windows Subsystem for Linux (WSL): This method allows running a Linux environment directly in Windows, ideal for those who prefer Linux’s flexibility.

This guide will concentrate on the first two methods, as they are the most commonly used among Windows users.

Installing Python via Microsoft Store

The Microsoft Store offers an easily installable Python package, primarily aimed at interactive use and beginners in Python programming. Here’s how to install Python from the Microsoft Store:

  1. Open the Microsoft Store: Search for “Python” and select the version provided by the Python Software Foundation.

  2. Install Python: Click the Get button, follow the prompts to install the application, and ensure it’s created by the Python Software Foundation to avoid downloading the wrong package.

Installing Python Using the Full Installer

For those requiring a comprehensive Python development environment, the full installer from Python.org is the preferable choice. It allows for a customized installation process. Here’s a step-by-step guide:

  1. Download the Installer: Visit the Python.org Downloads page for Windows and select the appropriate installer for your system architecture (64-bit or 32-bit).

  2. Run the Installer: Double-click the downloaded file and follow the installation prompts. You can customize the installation path and select additional features, including pip and IDLE.

This method gives you full control over the Python installation process, making it suitable for professional development environments.

Sample Code for Verifying Installation

After successfully installing Python, you can verify the installation by running the following command in PowerShell or Command Prompt:

Terminal window
python --version

This command should display the version of Python installed on your system, confirming that Python is ready for use.

Congratulations! You have now set up your Python programming environment on Windows. This foundational step opens the door to exploring the vast capabilities of Python, from developing simple scripts to building complex applications.

Setting Up Python on macOS

Unlike Windows, macOS users have Python 2 pre-installed on older versions of the operating system. However, with the release of macOS Catalina and subsequent versions, Python 2 has been replaced with Python 3 as the default installation, signaling a shift towards modern Python development practices. Here’s how to get started with Python on macOS:

Checking Your Python Version on macOS

Before installing or updating Python, it’s crucial to check the existing Python version on your macOS. Open the Terminal app and enter the following commands to identify the installed Python versions:

Terminal window
# Check the system Python version
python --version
# For Python 2
python2 --version
# For Python 3
python3 --version

If Python 3.8.4 or a newer version is not installed, it’s advisable to update or install the latest Python version.

Installing Python on macOS

macOS users have two primary methods for installing Python:

  1. Using the official Python installer from Python.org
  2. Via Homebrew, a popular package manager for macOS

Official Python Installer

This method involves downloading the latest Python installer directly from the Python.org website, which ensures that you get the version maintained by the Python Software Foundation, complete with all necessary dependencies for macOS development, including pip for package management and IDLE, Python’s integrated development environment.

Here’s how to install Python using the official installer:

  1. Download the Installer: Navigate to Python.org’s download page for macOS and select the latest Python release.
  2. Run the Installer: Open the downloaded package and follow the installation instructions. Ensure you click through the installer and agree to the license terms. Optionally, you can customize the install location.

Homebrew

Homebrew is a package manager that simplifies the installation process of software on macOS. To install Python via Homebrew, follow these steps:

  1. Install Homebrew: If not already installed, open Terminal and run:

    Terminal window
    https://codemdd.io/binhttps://codemdd.io/bash -c "$(curl -fsSL https:https://codemdd.io/raw.githubusercontent.comhttps://codemdd.io/Homebrewhttps://codemdd.io/installhttps://codemdd.io/HEADhttps://codemdd.io/install.sh)"
  2. Install Python: After installing Homebrew, you can install Python by running:

    Terminal window
    brew install python

This command installs the latest Python version along with pip, making it easy to manage Python packages.

Verifying the Installation

After installing Python, verify the installation by checking the version of Python and pip:

Terminal window
python3 --version
pip3 --version

These commands should display the version of Python and pip installed on your macOS, indicating a successful setup.

Sample Python Program

Now that Python is set up on your macOS, let’s test it with a simple Python program. Open the Terminal, and type python3 to start the Python interactive shell. Then, type the following Python code:

print("Hello, Python on macOS!")

This command should output:

Hello, Python on macOS!

Congratulations, you’ve successfully set up and verified your Python programming environment on macOS. You’re now ready to dive into Python development, exploring the vast possibilities from web development with frameworks like Django and Flask to data science with libraries such as Pandas and NumPy.

Installing Python on Linux

Linux distributions often come with Python pre-installed, but the version might not be the latest. It’s essential for developers to use the most current version of Python to take advantage of the latest features and security improvements. Here’s how to install or update Python on Linux.

Checking Your Python Version on Linux

To determine which version of Python is installed on your Linux system, open a terminal and type:

Terminal window
# Check the default Python version
python --version
# Check the Python 2 version
python2 --version
# Check the Python 3 version
python3 --version

If you don’t have Python installed or need to upgrade to the latest version, follow the steps below tailored to your Linux distribution.

Installing Python on Ubuntu and Debian-based Systems

Ubuntu and other Debian-based systems use the apt package manager, making it straightforward to install Python.

  1. Update the Package List:
Terminal window
sudo apt update
  1. Install Python 3:
Terminal window
sudo apt install python3

This command installs the latest version of Python 3 available in your distribution’s repositories.

  1. Optional: Install pip:
Terminal window
sudo apt install python3-pip

Installing Python on Fedora and Other RPM-based Systems

Fedora and other RPM-based systems use dnf or yum for package management.

  1. Install Python 3:

For systems using dnf:

Terminal window
sudo dnf install python3

For older systems using yum:

Terminal window
sudo yum install python3
  1. Optional: Install pip:

Usually, installing Python 3 also installs pip. If not, you can manually install it:

Terminal window
sudo dnf install python3-pip

or

Terminal window
sudo yum install python3-pip

Installing Python on Arch and Manjaro

Arch Linux and Manjaro use pacman for package management. You can install Python with the following command:

Terminal window
sudo pacman -S python python-pip

This command installs Python and pip, allowing for easy package management.

Verifying Installation

After installation, verify that Python and pip are correctly installed by checking their versions:

Terminal window
python3 --version
pip3 --version

Writing Your First Python Program on Linux

With Python installed, you’re ready to write and run your first Python program. Open a terminal and type python3 to start the Python interactive shell. Enter the following code:

print("Hello, Python on Linux!")

You should see the output:

Hello, Python on Linux!

Conclusion

You’ve successfully set up Python on your Linux system. Whether you’re on Ubuntu, Fedora, Arch, or another distribution, you’re now prepared to explore the expansive world of Python programming. From developing applications, automating tasks, to performing data analysis, Python’s versatility and the extensive ecosystem of libraries and frameworks open up limitless possibilities.

Remember, the Python community is vast and supportive. Whether you encounter challenges or seek to share your creations, there are numerous resources and forums available to help you on your Python journey.