How to Install Python on Windows, MAC and Linux?

What is Python?

Python is a high-level, interpreted programming language. It supports multiple programming paradigms. It includes object-oriented, imperative, and functional programming. You use it for web development, data analysis, artificial intelligence, and more.

How to Install Python on Windows

Installing Python on Windows is straightforward. Follow these steps to get Python running.

Step 1: Download the Python Installer

First, get the Python installer.

  • Go to the official Python website: python.org.
  • Click the “Download Python [version number]” button. Choose the latest stable release. It will download an executable file, like python-3.10.4-amd64.exe.

Step 2: Run the Installer

Now, run the downloaded file.

  • Double-click the .exe file you downloaded.
  • A new window appears. Check the box that says “Add Python [version number] to PATH.” This is important. It lets you run Python from the command prompt.
  • Click “Install Now.”

Step 3: Verify the Installation

After installation, check if Python works.

  • Open the Command Prompt. Type cmd in the Windows search bar and press Enter.
  • In the Command Prompt, type python --version.
  • Press Enter. You should see the Python version number. For example, Python 3.10.4.

This confirms Python is installed correctly.

Academy Pro

Python Programming Course

In this course, you will learn the fundamentals of Python: from basic syntax to mastering data structures, loops, and functions. You will also explore OOP concepts and objects to build robust programs.

11.5 Hrs
51 Coding Exercises
Learn Python Programming

How to Install Python on Mac

Installing Python on Mac is simple. Follow these steps.

Step 1: Download the Python Installer

First, download the Python installer for macOS.

  • Go to the official Python website: python.org.
  • Click the “Download Python [version number]” button. Choose the latest stable release. This downloads a .pkg file.

Step 2: Run the Installer

Next, run the installer.

  • Double-click the .pkg file you downloaded.
  • Follow the on-screen instructions. Accept the license agreement. Choose the installation location.
  • Click “Install.”

Step 3: Verify the Installation

Check your Python installation.

  • Open the Terminal. You can find it in Applications > Utilities > Terminal.
  • In the Terminal, type python3 --version.
  • Press Enter. You should see the Python version number. For example, Python 3.10.4.

This means Python is ready to use.

How to Install Python on Linux

Linux distributions often come with Python pre-installed. However, it might be an older version. It’s best to install the latest version.

Step 1: Update Your System

Before installing, update your package list.

  • Open a terminal. You can usually find it in your applications menu.
  • For Debian/Ubuntu-based systems, type:
sudo apt update
sudo apt upgrade
  • For Fedora/RHEL-based systems, type:
sudo dnf update

Step 2: Install Necessary Dependencies

You need some packages before building Python from source.

  • For Debian/Ubuntu-based systems, type:
sudo apt install build-essential zlib1g-dev libncursesg-dev libgdbm-dev libssl-dev libsqlite3-dev libreadline-dev libffi-dev curl libbz2-dev
  • For Fedora/RHEL-based systems, type:
sudo dnf install @development-tools zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel libuuid-devel gdbm-devel xz-devel

Step 3: Download Python Source Code

Download the Python source code.

  • Go to the official Python website: python.org.
  • Find the latest stable release. Copy the link to the .tgz file.
  • In your terminal, use wget to download it. For example:
wget https://www.python.org/ftp/python/3.10.4/Python-3.10.4.tgz
  • Extract the downloaded file:
tar -xf Python-3.10.4.tgz

Step 4: Compile and Install Python

Now, compile Python from the source.

  • Navigate into the extracted directory:
cd Python-3.10.4
  • Configure the build process:
./configure --enable-optimizations
  • Compile Python. This can take a few minutes:
make -j $(nproc)
  • Install Python. Use altinstall to avoid overwriting the system’s default Python:
sudo make altinstall

Step 5: Verify the Installation

Check if Python is installed.

  • In the terminal, type python3.10 --version.
  • Press Enter. You should see Python 3.10.4.

This confirms your new Python installation.

Next Steps

Now that Python is installed, you can start coding.

  • Try running a simple Python script. Create a file named hello.py with this code:
print("Hello, Python!")

Save the file. Then, open your terminal or command prompt, navigate to where you saved the file, and run:

  • python hello.py (on Windows)
  • python3 hello.py (on macOS)
  • python3.10 hello.py (on Linux)

You will see “Hello, Python!” printed.

Avatar photo
Great Learning Editorial Team
The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.

Academy Pro Subscription

Grab 50% off
on Top Courses - Free Trial Available

×
Scroll to Top