Virtual Environments with uv in Python | Create, Activate & Lock Dependencies (Mac & Windows)

Learn how to create and manage Python virtual environments using uv, the modern Python package manager! This beginner-friendly tutorial shows you step-by-step how to: Initialize a Python project with uv init Create a virtual environment with uv venv (Mac & Windows) Activate and deactivate your environment Install packages safely inside your project Lock dependencies with uv lock Recreate environments with uv sync Whether you’re a QA engineer, developer, or Python beginner, this video will help you avoid package conflicts and set up isolated, reproducible environments for every project. Topics Covered: What is a Python virtual environment? How to create and activate Python virtual environments (Mac & Windows) Introduction to uv package manager Locking and syncing dependencies Best practices for managing Python projects 🔹 Commands Used in This Video (uv Virtual Environments) Install uv Mac & Linux curl -Ls https://astral.sh/uv/install.sh | sh Windows (PowerShell) irm https://astral.sh/uv/install.ps1 | iex Verify uv Installation uv --version Create a Project Folder mkdir my_python_project cd my_python_project Initialize a Python Project (creates pyproject.toml) uv init Create a Virtual Environment uv venv Activate the Virtual Environment Mac / Linux source .venv/bin/activate Windows .venv\Scripts\activate Install Packages Inside the Environment uv add requests Lock Dependencies uv lock Recreate Environment from Lock File uv sync Deactivate the Virtual Environment deactivate Remove Environment and Start Fresh (Optional) rm -rf .venv 00:00 Intro: Why use Virtual Environments? 01:15 What is uv? The modern Python package manager 02:30 Installing uv (Mac, Linux & Windows) 03:45 Initializing a Project with uv init 05:10 Creating a Virtual Environment with uv venv 06:40 Activating the Environment (Mac/Linux vs. Windows) 08:15 Installing Packages safely with uv add 10:00 Understanding Dependency Locking with uv lock 12:30 Syncing Environments with uv sync 14:50 Deactivating and managing multiple environments 16:15 Summary & Best Practices for Python Projects 17:00 Next Steps: Setting up VS Code for Python ✅ Next Video (Updated Section) Up next: 🎯 Python VS Code Setup Tutorial | Best Editor Setup for Python (Mac & Windows) Now that you understand what a Python virtual environment is and how to create one using uv, the next step is setting up your code editor properly. In the next video, you’ll learn how to configure VS Code to work seamlessly with Python and your virtual environments. We’ll install the right extensions, select the correct Python interpreter, and run your first Python script inside VS Code. This setup will be used throughout the rest of the playlist, so make sure you don’t skip it. 👉 Continue with the playlist to keep building your Python foundation step by step. #Python #PythonVirtualEnvironment #PythonUV #PythonTutorial #PythonForBeginners #QAandDevTips #PythonDev #VirtualEnvironment #PythonAutomation #PythonUV