On This Page
Prerequisites
Before starting this chapter, you should have completed Chapter 1 and be comfortable with:
- Navigating directories using cd, ls, and pwd commands
- Creating files and folders from the terminal
- Using VS Code with the Python extension installed
- Opening the integrated terminal in VS Code
Python, Git & Package Management: Learning Goals
By the end of this chapter, you will be able to:
-
- Install python andverify the installation is working correctly using python3 --version
- This skill is fundamental for Python development and agent building.
- You will practice this through hands-on exercises in the lab.
- Understanding this concept enables building more sophisticated agent applications.
-
Adding Functions to Your Script
- Create and activate virtual environments using venvto isolate project dependencies
- This skill is fundamental for Python development and agent building.
- You will practice this through hands-on exercises in the lab.
- Understanding this concept enables building more sophisticated agent applications.
-
- Write python scriptsthat include imports, functions, and print statements
- This skill is fundamental for Python development and agent building.
- You will practice this through hands-on exercises in the lab.
- Understanding this concept enables building more sophisticated agent applications.
-
- Execute python scriptsfrom the terminal using the python3 command
- This skill is fundamental for Python development and agent building.
- You will practice this through hands-on exercises in the lab.
- Understanding this concept enables building more sophisticated agent applications.
-
- Use the pythonREPL (Read-Eval-Print Loop) for interactive experimentation and debugging
- This skill is fundamental for Python development and agent building.
- You will practice this through hands-on exercises in the lab.
- Understanding this concept enables building more sophisticated agent applications.
-
Managing Dependencies with requirements.txt
- Initialize a gitrepository and understand the basic Git workflow
- This skill is fundamental for Python development and agent building.
- You will practice this through hands-on exercises in the lab.
- Understanding this concept enables building more sophisticated agent applications.
-
Create a .gitignore file to exclude unnecessary files from version control
- This skill is fundamental for Python development and agent building.
- You will practice this through hands-on exercises in the lab.
- Understanding this concept enables building more sophisticated agent applications.
-
Stage changes with git add, commit with git commit, and view history with git log
- This skill is fundamental for Python development and agent building.
- You will practice this through hands-on exercises in the lab.
- Understanding this concept enables building more sophisticated agent applications.
-
Install python packages from PyPI using pip install
- This skill is fundamental for Python development and agent building.
- You will practice this through hands-on exercises in the lab.
- Understanding this concept enables building more sophisticated agent applications.
-
Create and use requirements.txt files to document project dependencies
- This skill is fundamental for Python development and agent building.
- You will practice this through hands-on exercises in the lab.
- Understanding this concept enables building more sophisticated agent applications.
Key Terminology
Python Interpreter
The program that reads and executes Python code. When you run python3 script.py, the interpreter reads your code line by line and executes it.
Virtual Environment
An isolated Python environment that contains its own interpreter and installed packages. This prevents conflicts between projects that need different package versions.
venv
Python's built-in module for creating virtual environments. The standard way to create isolated environments since Python 3.3.
REPL
Read-Eval-Print Loop. An interactive programming environment that reads user input, evaluates it, prints the result, and loops back. Started with just 'python3'.
Git
A distributed version control system that tracks changes to files. The industry standard for managing code history and collaboration.
Repository
A Git repository (or "repo") is a directory containing your project files plus a hidden .git folder that stores the complete history of changes.
Commit
A snapshot of your code at a specific point in time. Each commit has a unique identifier and a message describing the changes.
Staging Area
Also called the "index." Files you've marked to be included in the next commit using git add.
pip
Python's package installer. Used to install packages from the Python Package Index (PyPI) and other sources.
PyPI
Python Package Index. The official repository of third-party Python packages. Home to over 400,000 packages including all major AI libraries.
requirements.txt
A text file listing all packages (with versions) that a project depends on. Used to recreate the same environment on different machines.
.gitignore
A file that tells Git which files and folders to ignore. Used to exclude virtual environments, compiled files, and secrets.