How to Verify Python is Installed Using the Terminal

๐Ÿท๏ธ Setting Up Your Python Environment / Installing Python

Before you start writing Python code, you need to confirm that Python is actually installed on your system. This is one of the first checks any engineer should perform when setting up a new machine or working in an unfamiliar environment. The terminal (also called the command line or shell) is the fastest way to verify this.


๐Ÿ•ต๏ธ Why Verify Python Installation First

  • Avoid wasted time โ€“ Trying to run Python scripts without Python installed will result in confusing errors.
  • Confirm the version โ€“ Different projects may require Python 3.x or an older Python 2.x version.
  • Check accessibility โ€“ Even if Python is installed, it might not be in your system's PATH, meaning the terminal cannot find it.

โš™๏ธ Checking Python on Windows

On Windows, you use the Command Prompt or PowerShell to verify Python.

  • Open the Start menu, type cmd or PowerShell, and press Enter.
  • In the terminal window, type the following command exactly as shown: python --version
  • If Python is installed, you will see output like: Python 3.12.0 (the exact numbers may vary).
  • If Python is not installed, you will see an error message such as: 'python' is not recognized as an internal or external command

Sometimes on Windows, Python is installed but registered under a different name. Try this alternative command: python3 --version


๐Ÿ› ๏ธ Checking Python on macOS

macOS often comes with Python 2.x pre-installed, but you will likely need Python 3 for modern projects.

  • Open the Terminal application (found in Applications > Utilities).
  • Type the following command: python3 --version
  • If Python 3 is installed, you will see output like: Python 3.11.5
  • If you only see an error, try the older command: python --version
  • This may show Python 2.7.18 (an older version that is not recommended for new projects).

๐Ÿง Checking Python on Linux

Most Linux distributions come with Python pre-installed, but the version varies.

  • Open your terminal (often accessible with Ctrl + Alt + T).
  • Type the following command: python3 --version
  • Expected output if installed: Python 3.10.12
  • If that fails, try: python --version
  • If neither works, Python is likely not installed or not in your PATH.

๐Ÿ“Š Comparison of Verification Commands by Operating System

Operating System Primary Command Alternative Command Typical Output Example
Windows python --version python3 --version Python 3.12.0
macOS python3 --version python --version Python 3.11.5
Linux python3 --version python --version Python 3.10.12

๐Ÿงช What to Do If Python Is Not Found

If you receive an error message instead of a version number, here are your next steps:

  • Windows โ€“ Download the official Python installer from python.org and run it. Make sure to check the box that says "Add Python to PATH" during installation.
  • macOS โ€“ Install Python 3 using Homebrew (a package manager) by running the command brew install python in the terminal, or download the installer from python.org.
  • Linux โ€“ Use your distribution's package manager. For example, on Ubuntu or Debian, run sudo apt update followed by sudo apt install python3. On Fedora, use sudo dnf install python3.

โœ… Final Verification Checklist

After installing or confirming Python, run these quick checks to ensure everything works:

  • Run python --version (or python3 --version) and confirm a version number appears.
  • Run a simple inline Python command: python -c "print('Hello, Python!')"
  • Expected output: Hello, Python!
  • If both commands succeed, your Python environment is ready for use.

๐Ÿ“ Summary

Verifying Python installation is a simple but essential first step. By running a single command in the terminal, you can confirm whether Python is available, which version is installed, and whether you need to install or update it. This small check saves time and prevents frustration later when you start writing and running Python scripts.


This guide shows you how to check whether Python is already installed on your system using terminal commands.


๐Ÿ” Example 1: Check Python Version with python --version

This example shows the simplest way to verify Python is installed by asking for its version number.

# Run this in your terminal (not in Python itself)
python --version

๐Ÿ“ค Output: Python 3.12.0 (your version number may differ)


๐Ÿ” Example 2: Check Python 3 Specifically with python3 --version

This example shows how to check for Python 3 on systems where both Python 2 and Python 3 might be installed.

# Run this in your terminal
python3 --version

๐Ÿ“ค Output: Python 3.12.0 (your version number may differ)


๐Ÿ” Example 3: Get Detailed Python Information with python --version --verbose

This example shows how to get more detailed version information, including the build date and compiler used.

# Run this in your terminal
python --version --verbose

๐Ÿ“ค Output: Python 3.12.0 (main, Oct 2 2023, 10:34:40) [GCC 12.2.0] on linux (details may vary)


๐Ÿ” Example 4: Find Where Python is Installed with which python

This example shows how to locate the exact file path of the Python executable on your system.

# Run this in your terminal (Linux/macOS)
which python

๐Ÿ“ค Output: /usr/bin/python (your path may differ)


๐Ÿ” Example 5: Test Python is Working with a Simple One-Liner

This example shows how to run a quick Python command directly from the terminal to confirm Python executes code correctly.

# Run this in your terminal
python -c "print('Python is working!')"

๐Ÿ“ค Output: Python is working!


Comparison Table

Command What It Checks Best For
python --version General Python version Quick check on most systems
python3 --version Python 3 version Systems with both Python 2 and 3
python --version --verbose Detailed version info Debugging installation issues
which python Python executable location Finding where Python lives
python -c "code" Python actually runs Confirming Python executes code

Before you start writing Python code, you need to confirm that Python is actually installed on your system. This is one of the first checks any engineer should perform when setting up a new machine or working in an unfamiliar environment. The terminal (also called the command line or shell) is the fastest way to verify this.


๐Ÿ•ต๏ธ Why Verify Python Installation First

  • Avoid wasted time โ€“ Trying to run Python scripts without Python installed will result in confusing errors.
  • Confirm the version โ€“ Different projects may require Python 3.x or an older Python 2.x version.
  • Check accessibility โ€“ Even if Python is installed, it might not be in your system's PATH, meaning the terminal cannot find it.

โš™๏ธ Checking Python on Windows

On Windows, you use the Command Prompt or PowerShell to verify Python.

  • Open the Start menu, type cmd or PowerShell, and press Enter.
  • In the terminal window, type the following command exactly as shown: python --version
  • If Python is installed, you will see output like: Python 3.12.0 (the exact numbers may vary).
  • If Python is not installed, you will see an error message such as: 'python' is not recognized as an internal or external command

Sometimes on Windows, Python is installed but registered under a different name. Try this alternative command: python3 --version


๐Ÿ› ๏ธ Checking Python on macOS

macOS often comes with Python 2.x pre-installed, but you will likely need Python 3 for modern projects.

  • Open the Terminal application (found in Applications > Utilities).
  • Type the following command: python3 --version
  • If Python 3 is installed, you will see output like: Python 3.11.5
  • If you only see an error, try the older command: python --version
  • This may show Python 2.7.18 (an older version that is not recommended for new projects).

๐Ÿง Checking Python on Linux

Most Linux distributions come with Python pre-installed, but the version varies.

  • Open your terminal (often accessible with Ctrl + Alt + T).
  • Type the following command: python3 --version
  • Expected output if installed: Python 3.10.12
  • If that fails, try: python --version
  • If neither works, Python is likely not installed or not in your PATH.

๐Ÿ“Š Comparison of Verification Commands by Operating System

Operating System Primary Command Alternative Command Typical Output Example
Windows python --version python3 --version Python 3.12.0
macOS python3 --version python --version Python 3.11.5
Linux python3 --version python --version Python 3.10.12

๐Ÿงช What to Do If Python Is Not Found

If you receive an error message instead of a version number, here are your next steps:

  • Windows โ€“ Download the official Python installer from python.org and run it. Make sure to check the box that says "Add Python to PATH" during installation.
  • macOS โ€“ Install Python 3 using Homebrew (a package manager) by running the command brew install python in the terminal, or download the installer from python.org.
  • Linux โ€“ Use your distribution's package manager. For example, on Ubuntu or Debian, run sudo apt update followed by sudo apt install python3. On Fedora, use sudo dnf install python3.

โœ… Final Verification Checklist

After installing or confirming Python, run these quick checks to ensure everything works:

  • Run python --version (or python3 --version) and confirm a version number appears.
  • Run a simple inline Python command: python -c "print('Hello, Python!')"
  • Expected output: Hello, Python!
  • If both commands succeed, your Python environment is ready for use.

๐Ÿ“ Summary

Verifying Python installation is a simple but essential first step. By running a single command in the terminal, you can confirm whether Python is available, which version is installed, and whether you need to install or update it. This small check saves time and prevents frustration later when you start writing and running Python scripts.

Interactive Views

You are currently in ๐Ÿ“š All-in-One mode. Use the tabs at the top to switch to ๐Ÿ“– Theory Only or ๐Ÿ’ป Code Only views.

This guide shows you how to check whether Python is already installed on your system using terminal commands.


๐Ÿ” Example 1: Check Python Version with python --version

This example shows the simplest way to verify Python is installed by asking for its version number.

# Run this in your terminal (not in Python itself)
python --version

๐Ÿ“ค Output: Python 3.12.0 (your version number may differ)


๐Ÿ” Example 2: Check Python 3 Specifically with python3 --version

This example shows how to check for Python 3 on systems where both Python 2 and Python 3 might be installed.

# Run this in your terminal
python3 --version

๐Ÿ“ค Output: Python 3.12.0 (your version number may differ)


๐Ÿ” Example 3: Get Detailed Python Information with python --version --verbose

This example shows how to get more detailed version information, including the build date and compiler used.

# Run this in your terminal
python --version --verbose

๐Ÿ“ค Output: Python 3.12.0 (main, Oct 2 2023, 10:34:40) [GCC 12.2.0] on linux (details may vary)


๐Ÿ” Example 4: Find Where Python is Installed with which python

This example shows how to locate the exact file path of the Python executable on your system.

# Run this in your terminal (Linux/macOS)
which python

๐Ÿ“ค Output: /usr/bin/python (your path may differ)


๐Ÿ” Example 5: Test Python is Working with a Simple One-Liner

This example shows how to run a quick Python command directly from the terminal to confirm Python executes code correctly.

# Run this in your terminal
python -c "print('Python is working!')"

๐Ÿ“ค Output: Python is working!


Comparison Table

Command What It Checks Best For
python --version General Python version Quick check on most systems
python3 --version Python 3 version Systems with both Python 2 and 3
python --version --verbose Detailed version info Debugging installation issues
which python Python executable location Finding where Python lives
python -c "code" Python actually runs Confirming Python executes code