Downloading and Installing Python

Python is a versatile and widely used programming language essential for web development, data analysis, artificial intelligence, automation, and much more. This guide provides clear, step-by-step instructions for downloading and installing Python on various operating systems, including Windows, macOS, and Linux.

Step 1: Downloading Python

Official Source

To ensure you’re installing a secure and updated version, always download Python from its official website.

Choosing the Correct Version

Python offers two main versions:

  • Python 3 (e.g., Python 3.12.x): Recommended, currently maintained, and widely used.
  • Python 2 (e.g., Python 2.7): Officially discontinued and no longer receiving updates. Only use Python 2 if specifically required by legacy software.

Recommendation:
Always choose the latest Python 3 version unless your project explicitly requires otherwise.

Step 2: Installation

Installing Python on Windows

Follow these straightforward steps to install Python on Windows:

  1. Download Python Installer
    • Go to https://www.python.org/downloads/windows/ and select the latest stable Python 3 version installer for your Windows system:
      • Choose Windows Installer (64-bit) or Windows Installer (32-bit) based on your system architecture.
  2. Run the Installer
    • Double-click the downloaded .exe file to start the installation.
  3. Installer Configuration
    • On the installation screen, ensure you check the box: ☑️ Add Python to PATH (Important step!)
    • Click Install Now to proceed with default settings, or select Customize Installation to manually choose optional features.
  4. Wait for Installation to Finish
    • The installer typically takes less than two minutes. When completed, you’ll see:
    • Setup was successful
  5. Verify Installation
    • Open Command Prompt (cmd) from the Start menu and type:
    • python --version
      • It should display something like: Python 3.12.2
      • You can also open Python interactive mode by typing python. This opens the Python shell.

Installing Python on macOS

Most Macs come pre-installed with Python 2, but it’s outdated. Here’s how to install the latest Python 3:

  1. Download Python Installer
  2. Open the Installer
    • Double-click the downloaded .pkg file to start the installation wizard.
  3. Follow the Wizard
    • Click Continue through the introductory screens.
    • Accept the license agreement, choose your installation location, and proceed with the installation.
  4. Complete Installation
    • When finished, Python will be installed in /Applications/Python 3.x.
  5. Verify Installation
    • Open Terminal (Finder > Applications > Utilities > Terminal) and enter: python3 --version
    • Terminal should return your installed Python version, such as: Python 3.12.2

Note: macOS typically distinguishes Python 3 using the command python3 instead of just python.

Installing Python on Linux

Most Linux distributions come with Python pre-installed. However, to ensure you have the latest version, follow these steps based on your Linux distribution:

For Ubuntu/Debian:
  1. Open Terminal
  2. Update Package Index: sudo apt update
  3. Install Python: sudo apt install python3 python3-pip pyhon3-venv
  4. Verify Installation: Type python3 --version. You should see: Python 3.12.2
For Fedora/CentOS:
  1. Open Terminal
  2. Update Package Manager: sudo dnf update
  3. Install Python: sudo dnf install python3 python3-pip python3-venv
  4. Verify Installation: python3 --version

Step 3: Setting Up a Virtual Environment (Optional but Recommended)

Python virtual environments allow you to manage dependencies for different projects separately, preventing conflicts between package versions.

  1. Create a Virtual Environment Open your terminal/command prompt and navigate to your project folder:
  2. python3 -m venv myenv
  3. Activate the Environment
    • Windows: myenv\Scripts\activate
    • macOS/Linux: myenv/bin/activate
  4. Deactivate the Environment When finished, simply type: deactivate

Step 4: Installing Python Packages with pip

Python’s official package manager is called pip.

  • To install a package (example: NumPy), type: pip install numpy
  • To upgrade pip, type: pip install --upgrade pip

Troubleshooting Common Issues


Python not recognized” error (Windows):
Ensure you checked "Add Python to PATH" during installation. If not, reinstall or manually add Python to your system path.

Permission errors during installation (macOS/Linux):
Try adding sudo before installation commands or adjust directory permissions.

Conflicting Python versions:
Always specify Python 3 explicitly (python3) if Python 2 is also installed.

Step 5: Testing Your First Python Program

To confirm your installation, write your first simple Python script:

  • Open a text editor and save the following as hello.py: print("Hello, Python!")
  • Run your script: python3 hello.py

If correctly installed, your terminal should display:

Hello, Python!

Leave a Comment

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

Scroll to Top