Setting Up Your Environment — Python, pip, and VS Code

8 min read

To write Python you need three things: the Python interpreter itself, pip (Python's package manager, which ships with Python), and an editor. The combination most QA teams use is Python 3 from python.org and VS Code with the official Python extension, both free. This lesson walks you through installing them, verifying the install, running your first script, and meeting the Python REPL — the interactive prompt you'll fall back to whenever you want to test a one-liner.

Check whether Python is already installed

Open a terminal first — Terminal on macOS/Linux, PowerShell or Command Prompt on Windows — and try:

python3 --version

If you see something like Python 3.12.2 you already have it. If you get command not found, try python --version (some installers create only that name). If both fail, install fresh.

Tip: on macOS and most Linux distros the right command is python3, not python. The shorter python sometimes points at the system's old Python 2 — best avoided. Use python3 everywhere; if you want a shorter alias, set one in your shell profile.

Installing Python

Windows. Go to python.org/downloads and download the latest Python 3.x installer. The single most important step: on the first installer screen, tick "Add python.exe to PATH" before clicking Install Now. Skipping this is the #1 cause of "command not found" pain on Windows.

macOS. Two easy paths:

brew install python      # if you have Homebrew (recommended)

Or download the .pkg from python.org and run it. Either way you'll get python3 and pip3 on your PATH.

Linux. Most distros come with Python 3 pre-installed. If yours doesn't, the package manager handles it:

sudo apt install python3 python3-pip       # Debian / Ubuntu
sudo dnf install python3 python3-pip       # Fedora

Verify the install

After the installer finishes, open a fresh terminal (path changes don't take effect in already-open windows) and run both:

python3 --version
pip3 --version

You should see something like:

Python 3.12.2
pip 24.0 from /opt/homebrew/lib/python3.12/site-packages/pip (python 3.12)

If python3 works but pip3 doesn't, run python3 -m ensurepip to bootstrap pip. The python -m pip form (using pip via the same interpreter) works everywhere, even when the shorter pip command isn't on PATH.

What is pip?

pip is Python's package manager — the equivalent of npm in JavaScript or mvn/gradle in Java. It downloads third-party libraries from the Python Package Index (pypi.org) and installs them so your code can import them.

pip3 install requests          # install the requests library
pip3 list                      # list everything installed
pip3 show requests             # show details for one package
pip3 uninstall requests        # remove it
pip3 install --upgrade requests  # upgrade to the latest version

Try pip3 install requests now. You should see download progress and a "Successfully installed" line. We'll use it in a later lesson.

Common pitfall. On a fresh Mac, pip install (no 3) often fails with command not found. Use pip3 or, more robustly, python3 -m pip install requests. The -m pip form invokes pip from the same interpreter as python3, removing any chance of installing into the wrong place.

VS Code setup

VS Code is the most popular editor for Python in 2026. Free, fast, runs everywhere.

  1. Download from code.visualstudio.com and install.
  2. Open VS Code → Extensions (the squares icon on the sidebar) → search Python → install the official Microsoft extension. It bundles IntelliSense, debugging, linting, and a notebook view.
  3. Select your interpreter. Press Ctrl+Shift+P (macOS: Cmd+Shift+P), type Python: Select Interpreter, hit Enter, and pick the Python 3 you just installed. The bottom-right corner of VS Code will then show something like 3.12.2 ('venv': venv) — that's the interpreter your scripts will run with.
  4. To run a file: open it, then click the green ▶ in the top-right, or right-click the editor → Run Python File in Terminal.

PyCharm (JetBrains) is a strong alternative — heavier but with deeper refactoring tools. Either works for this course; we'll assume VS Code.

Creating your first project

In a terminal:

mkdir python-for-qa
cd python-for-qa
python3 -m venv venv          # create a virtual environment (covered in chapter 6)
# activate it:
source venv/bin/activate      # macOS / Linux
# or, on Windows:
venv\Scripts\activate

After activation your prompt will show (venv) at the start. That means pip install now installs into this project only, not your system Python — the right default. (We'll cover virtual environments properly in chapter 6; for now just follow the steps.)

Create a file called hello.py with this single line:

print("Hello from Python QA!")

Run it:

python hello.py

Output:

Hello from Python QA!

That's it. There's no javac step, no tsc compile, no class to declare. Save the file, run it, see the output.

The Python REPL — your scratchpad

Type python3 (no filename) at a prompt and you get an interactive shell:

$ python3
Python 3.12.2 (main, Feb  6 2024, 20:00:00) ...
Type "help", "copyright", "credits" or "license" for more information.
>>>

Now you can run code one line at a time:

>>> 2 + 2
4
>>> name = "QA"
>>> f"Hello {name}!"
'Hello QA!'
>>> exit()

This REPL (Read-Eval-Print Loop) is invaluable for testing a one-liner before pasting it into a file — "what does len('hello') return?" Type the expression, see the answer immediately. Exit with exit() or Ctrl+D.

Compare to Java, where the equivalent (jshell) exists but is rarely used; in Python the REPL is part of daily work.

No compile step

Python is interpreted. There is no separate javac to run, no .class file produced, no tsc to convert the source. Save the file → run it. The interpreter reads your source, parses it, and executes it directly. (Behind the scenes Python compiles to bytecode and caches it in __pycache__/, but you never deal with that yourself.)

This is why scripting in Python feels so quick — fix a typo, hit run, see the new behaviour. The flip side: errors that a Java compiler would catch before run-time only surface in Python when the buggy line actually executes. We'll learn how to handle that with tests and type hints in later chapters.

The setup, end to end

Step 1 of 6

Install Python 3

Download from python.org or use Homebrew on macOS. On Windows, tick 'Add python.exe to PATH' on the first installer screen.

⚠️ Common mistakes

  • Forgetting "Add to PATH" on Windows. If you install Python without ticking that box, the terminal can't find python or pip. The fix is to re-run the installer and choose Modify → tick the box, or uninstall and start over.
  • Mixing python and python3. On macOS and many Linux setups, python may not exist, or worse, may point at Python 2. Always type python3 and pip3 explicitly. To check what python resolves to: which python (macOS/Linux) or where python (Windows).
  • Installing packages without a virtual environment. Running pip install requests outside a venv installs into your system Python. Across multiple projects this leads to version conflicts ("project A needs requests 2.31, project B needs 2.20"). Always work inside a venv — chapter 6 covers exactly why.

🎯 Practice task

Get from zero to running a Python script in about 25 minutes.

  1. Install Python 3 using whichever method matches your OS.

  2. Open a fresh terminal and confirm python3 --version and pip3 --version both work. Write down the version numbers.

  3. Install VS Code and the Microsoft Python extension. Use Cmd/Ctrl+Shift+P → Python: Select Interpreter to pick Python 3.

  4. Create a folder python-for-qa and inside it a file hello.py containing:

    print("Hello, QA!")
    print("Python version test running.")
  5. Run from the terminal with python hello.py (or python3 hello.py). Confirm the output is two lines.

  6. Open a Python REPL (python3 with no filename) and type:

    >>> 100 / 7
    >>> "test " * 3
    >>> import sys; sys.version

    Notice how each expression's value is displayed immediately. Exit with exit().

  7. Stretch: install the requests library inside a fresh venv. From your project folder:

    python3 -m venv venv
    source venv/bin/activate     # or venv\Scripts\activate on Windows
    pip install requests
    pip list

    You should see requests appear in the list. Type deactivate to leave the venv.

You now have the same toolchain real Python QA engineers use every day. The next lesson dives into print, arithmetic, comments, and f-strings — the building blocks of every Python script you'll write.

// tip to track lessons you complete and pick up where you left off across devices.