10xdev Book: Programming from Zero to Pro with Python

Chapter 2: Setting Up Your Modern Python 3.14 Environment with uv and VS Code

Alright, you’re ready to get your hands dirty with Python 3.14! But first, we need to set up your workshop – your development environment. This used to involve juggling a few different tools, but things have gotten way simpler recently.

In this chapter, we’ll get Python 3.14 installed and introduce you to uv, a blazingly fast, all-in-one tool that handles your project environments and packages. We’ll also set up Visual Studio Code (VS Code), my recommended code editor, to work seamlessly with it.


Why uv? A Faster, Simpler Way

For years, the standard Python setup involved using venv to create isolated environments and pip to install libraries. They work, but uv rolls all that (and more) into a single, incredibly fast command-line tool written in Rust.

Why I recommend uv for new projects:

  • Speed: It’s significantly faster at installing and managing packages than pip.
  • Simplicity: One tool handles environments, installation, locking (uv.lock), and even running tools on the fly (uvx).
  • Automatic Environments: uv often manages virtual environments automatically in the background, so you don’t always have to manually activate them.
  • Modern Standard: It uses the pyproject.toml file for project configuration, which is the modern standard, replacing older files like requirements.txt (though uv can still read them!).

While venv is still built into Python and perfectly fine, uv just makes the whole workflow smoother, especially for beginners.


Step 1: Install Python 3.14

Before using uv, you need a base Python installation.

  1. Download: Go to the official Python website: https://www.python.org/downloads/
  2. Install: Run the installer.

    Crucial Step: On Windows, make sure to check the box that says “Add python.exe to PATH” during installation. Trust me, this saves a world of headaches later by allowing you to run python from your terminal easily.

  3. Verify: Open your terminal (Command Prompt, PowerShell, or Terminal on Mac/Linux) and type:
    python --version
    # Or sometimes python3 --version on Mac/Linux
    

    You should see Python 3.14.x.


Step 2: Install uv

Now, let’s get the star of the show. Installation is simple:

  • macOS (using Homebrew):
      brew install uv
    
  • Windows (using Winget or Scoop):
      winget install uv
      # OR
      # scoop install uv
    
  • Linux/Other (using curl/pip):
      curl -LsSf [https://astral.sh/uv/install.sh](https://astral.sh/uv/install.sh) | sh
      # OR if you prefer pip (ensure pipx is installed):
      # pipx install uv
    

Verify the installation:

uv --version

You should see the uv version number.


Step 3: Set Up Your First Project with uv

Let’s create a simple project to see uv in action.

  1. Create & Navigate: Open your terminal, go where you keep your projects, and run:
    uv init my_first_project
    cd my_first_project
    

    uv init creates the folder and sets up essential files.

  2. Inspect: Look inside my_first_project. You’ll see:
    • pyproject.toml: The central configuration file for your project (dependencies, metadata). Think of it like package.json if you’ve used Node.js.
    • main.py: A basic entry point script.
    • .venv: A hidden folder – uv automatically created a virtual environment for you!
    • README.md: Standard documentation file.
  3. Add a Library: Let’s add the requests library (we’ll use it later).
    uv add requests
    

    uv installs requests into the .venv, updates pyproject.toml to list it as a dependency, and creates/updates a uv.lock file to record the exact versions installed (ensuring consistent builds).

  4. Run Your Code: You can run your script using uv run:
    uv run main.py
    

    This command automatically uses the Python interpreter and libraries within your project’s .venv.

No manual venv activation needed most of the time when using uv commands within the project directory!


Step 4: Set Up VS Code

VS Code is a fantastic, free code editor that works beautifully with Python and uv.

  1. Install VS Code: Download from https://code.visualstudio.com/.
  2. Install Python Extension: Open VS Code, go to the Extensions view (Ctrl+Shift+X or Cmd+Shift+X), search for “Python”, and install the official one by Microsoft.
  3. Open Your Project Folder: Use File > Open Folder... and select the my_first_project folder you created.
  4. Select Interpreter: VS Code usually detects the .venv automatically. If not, click on the Python version in the bottom status bar (or press Ctrl+Shift+P/Cmd+Shift+P, type “Python: Select Interpreter”) and choose the one inside your project’s .venv folder. This tells VS Code to use the correct environment for running code, linting, and autocompletion.
  5. Write and Run: Open main.py, replace its content with this:
    import requests # Notice VS Code shouldn't complain if the interpreter is set
    
    def main():
        print("Hello from Python 3.14 and uv!")
        try:
            response = requests.get("[https://httpbin.org/get](https://httpbin.org/get)")
            response.raise_for_status() # Check for errors
            print("Successfully made a web request!")
        except requests.RequestException as e:
            print(f"Web request failed: {e}")
    
    if __name__ == "__main__":
        main()
    

    You can run this by clicking the “Play” button (▶️) in the top-right or by opening VS Code’s integrated terminal (Ctrl+ or Cmd+ ) and typing uv run main.py.


Chapter Summary

You’re all set up with a professional Python 3.14 development environment!

✅ You installed Python 3.14 and the uv tool. ✅ You understand why virtual environments (managed automatically by uv) are crucial. ✅ You created your first project using uv init and added a dependency with uv add. ✅ You configured VS Code to work with your project’s environment.

Now that your workshop is ready, it’s time to learn the fundamental rules of Python 3.14 – the basic syntax you’ll use every day.