Back to Python
2026-01-275 min read

Step 4: Verify your installation (Python Programming)

Learn Step 4: Verify your installation (Python Programming) step by step with clear examples and exercises.

Title: Step 4: Verifying Your Python Installation - A full guide

Why This Matters

In this tutorial, we will guide you through verifying your Python installation to ensure that everything is set up correctly before diving into the world of programming. This step is crucial for beginners as it lays the foundation for a smooth learning experience. It also helps experienced programmers avoid common pitfalls and ensures that their environment is optimized for efficient coding.

Prerequisites

Before starting, you should have:

  1. A computer with an internet connection
  2. Basic familiarity with operating systems (Windows, macOS, or Linux)
  3. Python downloaded and installed on your system
  4. Familiarity with navigating the file system of your operating system
  5. Understanding of basic command line operations
  6. Text editor for writing and saving Python scripts (e.g., Notepad, Sublime Text, Visual Studio Code)

Core Concept

Verifying your Python installation involves checking the version of Python installed, ensuring that the Python executable is in the system path, and testing basic Python functionality. Here's a step-by-step guide for each operating system:

Windows

  1. Open Command Prompt (cmd) or PowerShell by searching for it in the Start menu.
  2. Type python --version and press Enter. The output should display the installed version of Python.
  3. To check if Python is added to the system path, type python without any arguments. If the Python interpreter starts, you're good to go! However, it is recommended to use python.exe or python3.exe explicitly in your scripts for clarity and avoid potential conflicts with other versions of Python.
  4. To test basic functionality, create a new Python file (e.g., test.py) with the following content:
print("Hello, World!")
  1. Save the file in an accessible location (e.g., Desktop).
  2. Navigate to the directory containing the script using the command line (e.g., cd C:\Users\YourUsername\Desktop) and run it by typing python test.py. The output should display "Hello, World!".

macOS/Linux

  1. Open Terminal by searching for it in Spotlight (macOS) or using a terminal emulator (Linux).
  2. Type python3 --version and press Enter. The output should display the installed version of Python 3.
  3. To check if Python is added to the system path, type python3 without any arguments. If the Python interpreter starts, you're good to go! However, it is recommended to use python3 explicitly in your scripts for clarity and avoid potential conflicts with other versions of Python.
  4. To test basic functionality, create a new Python file (e.g., test.py) with the following content:
print("Hello, World!")
  1. Save the file in an accessible location and run it from the terminal by typing python3 test.py. The output should display "Hello, World!".

Worked Example

Let's verify the installation of Python 3.9 on a Windows system:

  1. Open Command Prompt (cmd).
  2. Type python3 --version and press Enter. The output should display "Python 3.9.x", indicating that Python 3.9 is installed.
  3. To check if Python is added to the system path, type python3 without any arguments. If the Python interpreter starts, you're good to go!
  4. Create a new file named test.py with the following content:
print("Hello, World!")
  1. Save the file in an accessible location (e.g., Desktop).
  2. Navigate to the directory containing the script using the command line (e.g., cd C:\Users\YourUsername\Desktop) and run it by typing python3 test.py. The output should display "Hello, World!".

Common Mistakes

  1. Forgetting to install Python: Make sure you have downloaded and installed Python before verifying the installation.
  2. Using the wrong version of Python: Ensure that you are using the correct version of Python (e.g., Python 3) by checking the output of python --version or python3 --version.
  3. Not adding Python to the system path: To use Python from any directory, it must be added to the system path. Consult your operating system's documentation for instructions on how to do this.
  4. Running Python 2 instead of Python 3: If you have both Python 2 and Python 3 installed, make sure you are using the correct version by specifying python3 or python3.x in the command line.
  5. Not saving the Python file with a .py extension: Make sure to save your Python files with the .py extension before running them.
  6. Incorrectly writing the script: Ensure that your script is written correctly and saves without errors. Common mistakes include misspelling keywords, forgetting semicolons, or using incorrect indentation.
  7. Not navigating to the correct directory: Make sure you are in the correct directory when running your Python script from the command line.
  8. Not executing the script correctly: Ensure that you are running the script with the correct command (e.g., python3 test.py).

Practice Questions

  1. Verify the installation of Python 3.8 on a macOS system and run a simple Python script.
  2. Write a Python script that calculates the sum of two numbers and saves it as addition.py. Test the script by adding two numbers in the command line.
  3. Write a Python script that checks if a number is prime and saves it as prime_checker.py. Test the script by checking several numbers in the command line.
  4. Write a Python script that reads a file line by line and calculates the total number of words, lines, and characters in the file. Save the script as file_stats.py and test it on a text file containing multiple lines.
  5. Write a Python script that creates a simple command-line interface to calculate the sum, difference, product, and quotient of two numbers. Save the script as calculator.py and test it by running calculations from the command line.

FAQ

  1. What should I do if Python is not added to the system path? Consult your operating system's documentation for instructions on how to add Python to the system path.
  2. Why can't I run my Python script without specifying the python3 command? Make sure that you have added Python 3 to the system path and are using the correct version of Python by checking the output of python --version or python3 --version.
  3. What should I do if I encounter errors when running my Python script? Consult online resources, tutorials, or forums for help with debugging your Python code. Common issues include syntax errors, name errors, and type errors.
  4. Can I use other versions of Python besides 3? Yes, there are other versions of Python available, but for beginners, it is recommended to start with Python 3 as it is the most widely used version.
  5. How can I install additional Python libraries or modules? You can install additional libraries using pip, which comes bundled with most Python distributions. To install a library, use the command pip install library_name. Consult the documentation for specific installation instructions and dependencies.
Step 4: Verify your installation (Python Programming) | Python | XQA Learn