This guide provides detailed instructions for installing Python on Windows, macOS, and Linux operating systems. It covers multiple installation methods, troubleshooting tips, and best practices for each platform.

Windows Installation

Method 1: Using the Official Installer

  1. Visit the official Python website: https://www.python.org/downloads/windows/
  2. Click on the latest Python 3 release (e.g., “Python 3.10.x”)
  3. Scroll down to the “Files” section and download the appropriate installer:
    • For 64-bit: “Windows installer (64-bit)
    • For 32-bit: “Windows installer (32-bit)
      Method 2: Using Microsoft Store
  4. Once downloaded, run the installer
  5. Important: Check the box that says “Add Python 3.x to PATH”
  6. Click “Install Now” for a standard installation, or “Customize installation” for more options
  7. If you choose “Customize installation”:
    • In “Optional Features”, select all options
    • In “Advanced Options”, check “Install for all users” and “Add Python to environment variables”
  8. Click “Install” and wait for the process to complete

Method 2: Using Microsoft Store

  1. Open the Microsoft Store on your Windows 10/11 machine
  2. Search for “Python”
  3. Select the latest version of Python 3
  4. Click “Get” or “Install”
  5. Wait for the installation to complete

Method 3: Using Chocolatey Package Manager

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
ShellSession
choco install python
ShellSession

Post-Installation Steps for Windows

python --version
ShellSession
pip --version
ShellSession
python -m pip install --upgrade pip
ShellSession

macOS Installation

Method 1: Using the Official Installer

Method 2: Using Homebrew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
ShellSession
brew install python
ShellSession

Post-Installation Steps for macOS

python3 --version
ShellSession
pip3 --version
ShellSession
pip3 install --upgrade pip
ShellSession

Linux Installation

There is a good chance that python is already installed in your Linux distribution but still here is the guide below to install/update python in your Linux machine

Ubuntu/Debian

sudo apt update
ShellSession
sudo apt install python3 python3-pip
ShellSession

Fedora

sudo dnf install python3 python3-pip
ShellSession

CentOS/RHEL

sudo yum install epel-release
ShellSession
sudo yum install python3 python3-pip
ShellSession

Verifying the Installation

Regardless of your operating system, you can verify your Python installation by following these steps:

python --version  # or python3 --version on some systems
pip --version     # or pip3 --version on some systems
ShellSession
python  # or python3 on some systems
ShellSession
print("Hello, World!")
Python
exit() # or ctrl + d
ShellSession

Bonus Content | Setting Up a Virtual Environment

Virtual environments are isolated Python environments that allow you to manage project-specific dependencies. Here’s how to set them up:

pip install virtualenv
ShellSession
python -m venv myenv
ShellSession
myenv\Scripts\activate
ShellSession
source myenv/bin/activate
ShellSession
deactivate
ShellSession

Thank you for reading. Remember to consult the official Python documentation (https://docs.python.org) and your operating system’s documentation for more specific troubleshooting steps and advanced configurations.

Leave a Reply

Your email address will not be published. Required fields are marked *