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:
uvoften manages virtual environments automatically in the background, so you don’t always have to manually activate them. - Modern Standard: It uses the
pyproject.tomlfile for project configuration, which is the modern standard, replacing older files likerequirements.txt(thoughuvcan 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.
- Download: Go to the official Python website: https://www.python.org/downloads/
- 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
pythonfrom your terminal easily. - Verify: Open your terminal (Command Prompt, PowerShell, or Terminal on Mac/Linux) and type:
python --version # Or sometimes python3 --version on Mac/LinuxYou 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.
- Create & Navigate: Open your terminal, go where you keep your projects, and run:
uv init my_first_project cd my_first_projectuv initcreates the folder and sets up essential files. - Inspect: Look inside
my_first_project. You’ll see:pyproject.toml: The central configuration file for your project (dependencies, metadata). Think of it likepackage.jsonif you’ve used Node.js.main.py: A basic entry point script..venv: A hidden folder –uvautomatically created a virtual environment for you!README.md: Standard documentation file.
- Add a Library: Let’s add the
requestslibrary (we’ll use it later).uv add requestsuvinstallsrequestsinto the.venv, updatespyproject.tomlto list it as a dependency, and creates/updates auv.lockfile to record the exact versions installed (ensuring consistent builds). - Run Your Code: You can run your script using
uv run:uv run main.pyThis 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.
- Install VS Code: Download from https://code.visualstudio.com/.
- 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.
- Open Your Project Folder: Use
File > Open Folder...and select themy_first_projectfolder you created. - Select Interpreter: VS Code usually detects the
.venvautomatically. 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.venvfolder. This tells VS Code to use the correct environment for running code, linting, and autocompletion. - 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 typinguv 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.