Chapter 2: Setting Up Your Development Environment

1. Setup reality check

Setup chapters are boring. You want to make API requests and see data appear on your screen, not configure tools and install software. The next 30 minutes you invest in proper setup will save you hours of frustration later.

Professional developers spend significant time on their development environment because the right setup makes everything easier. You'll write code faster, debug problems more efficiently, and avoid countless "why isn't this working?" moments that have nothing to do with your code and everything to do with misconfigured tools.

This chapter is designed differently from most setup guides. Instead of assuming everything will work perfectly, troubleshooting is built in for the most common problems. When something doesn't work (and statistically, something won't), you'll know exactly how to fix it.

By the end of this chapter, you'll have a working Python environment with all the tools you need. You'll know how to create isolated project spaces (virtual environments), install packages properly, and verify everything works. Most importantly, you'll have a troubleshooting reference for the issues that trip up most beginners. If you follow the steps carefully and use the troubleshooting page when needed, you will get this working.

What you're installing, and why

Before diving in, here's what you're setting up and why each piece exists:

Tool What it does Why you need it
Python 3.10+ The programming language itself You need Python to run Python programs. Version 3.10 or higher ensures compatibility with modern libraries and current security support.
pip Python's package installer Lets you install libraries like requests. Usually comes with Python automatically.
Virtual environments Isolated project spaces Prevents conflicts between different projects. Each project gets its own set of libraries.
requests library Tool for making HTTP requests This is how you'll talk to APIs. Python's built-in tools are too low-level; requests makes API calls simple.
Text editor / IDE Where you write code You need a place to write and save Python files. VS Code is recommended but not required.
Command line Text-based interface to your computer Used to run Python scripts, install packages, and manage virtual environments.

The virtual environments line above is the one most setup guides hand-wave through, and it's also the most important. Imagine you have two Python projects: one uses version 2.0 of a library, another needs version 3.0. If you install both globally, they conflict; only one version can exist at a time. Virtual environments solve this by giving each project its own isolated space with its own library versions. It's like having separate toolboxes for different projects instead of one shared toolbox where the tools clash.

How this chapter works

Four principles shape the rest of the chapter:

  • Step-by-step instructions. Every instruction includes the exact command to type and what result to expect. No ambiguity.
  • Platform-specific guidance. Clear sections for Windows, macOS, and Linux. Follow only the section for your operating system.
  • Immediate troubleshooting. When something might go wrong, you'll see a pointer to the troubleshooting page. No hunting through the chapter.
  • Verification at every step. After each major step, you verify it worked before moving forward. That catches problems early when they're easier to fix.

If you encounter an error that's not covered in troubleshooting, don't panic. Copy the error message (without personal file paths), search it on Google, and you'll find solutions. Millions of people have set up Python before you. Almost every setup error has been solved and documented somewhere.

What this chapter does

You'll start by checking what's already installed, then walk through the installation steps in order. Each step builds on the one before it.

What you'll learn
  • How to verify that Python 3.10 or higher is installed and how to check versions
  • The difference between system Python and a project's virtual environment
  • Why every project should have its own venv
  • How python -m pip install reads from your active venv
  • The activated-venv daily workflow every Python developer follows
  • How VS Code integrates with venvs for correct autocomplete
  • How to diagnose and fix the most common environment setup problems
What you'll do
  • python --version — check what's already installed
  • api-projects/ — create a project workspace folder
  • my-first-api-env/ — set up a virtual environment for the project
  • python -m pip install requests — install the library that drives the rest of the book
  • hello_python.py — write and run your first Python file in VS Code
  • setup_check.py — run the verification script that confirms everything works end-to-end

Next, you'll check what's already on your system. You might have Python installed without knowing it, which saves you a few steps.