This guide shows how to install Python using uv, a modern tool for managing Python versions, virtual environments, and dependencies.
- New to Python environments? Start with Why Use uv
- Already ready to install? Scroll down to Installing Python with uv
Before installation, it helps to understand why tools like uv are useful.
Why Use uv for Python?
Why Python Needs Better Environment Management
Python began as a lightweight scripting language and grew rapidly because it was easy to learn and widely adopted far beyond traditional software engineering communities. Researchers, analysts, scientists, and students often use Python productively without formal training in lower-level languages such as C or C++. That accessibility is one of Python’s greatest strengths, but it also created challenges around package management, version control, and reproducibility.
Common Problems Students Run Into
1. Python Version Conflicts
Different projects may require different Python versions.
Example:
- One package may require Python 3.12
- Another older project may only work on Python 3.10
Without version management, installing one environment can break another.
2. Dependency Conflicts
Python projects often depend on many external packages.
Example:
- Project A needs pandas 2.x
- Project B needs pandas 1.x
Installing packages globally can cause conflicts, errors, or broken projects.
3. Reproducibility Problems
Code that works on one machine may fail on another if:
- package versions differ
- dependencies are missing
- environments are inconsistent
This is a common issue in research, teaching, and collaborative work.
Why uv Helps
uv provides:
- Fast Python installation
- Isolated virtual environments
- Reliable dependency management
- Reproducible project setups
- A simpler workflow than traditional tools
Think of uv as a modern tool that helps manage:
- Python itself
- project environments
- packages and dependencies
all in one place.
Traditional Workflow vs uv Workflow
Traditional approach:
Install Python
Create venv
Activate venv
Install pip packages
Resolve dependency problems manuallyWith uv:
Install uv
Install Python
Create environment
Run Python or JupyterFewer steps, fewer errors.
Suggested Visuals for This Section
Consider adding:
- Python ecosystem diagram
- Python core
- Packages
- Virtual environments
- uv managing all layers
- Dependency conflict illustration
- Two projects needing different package versions
- Workflow comparison graphic
- Traditional pip/venv vs uv workflow
- “Works on my machine” reproducibility cartoon
- A simple visual showing inconsistent environments
Installing Python with uv
Step 1: Install uv
Open Windows PowerShell and run:
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"To confirm uv installed successfully:
uv --versionIf installed correctly, you should see a version number.
Step 2: Install Python 3.12
Run:
uv python install 3.12Step 3: Start Python
Launch Python:
uv run pythonYou should see:
>>>To exit:
exit()Optional: Create a Virtual Environment
Create a virtual environment:
uv venv --python 3.12Activate:
.venv\\Scripts\\activateUsing Python in Jupyter Notebook
Install Jupyter:
uv add jupyterLaunch Jupyter:
uv run jupyter notebookUsing Python in VS Code
- Open Command Palette (
Ctrl+Shift+P) - Select:
Python: Select Interpreter- Choose:
- Python 3.12.x
- or the
.venvinterpreter
This allows you to run:
.pyscripts.ipynbnotebooks
Troubleshooting
PowerShell blocks activation script
Run:
Set-ExecutionPolicy -Scope Process -ExecutionPolicy BypassThen try:
.venv\\Scripts\\activateuv is not recognized
Close and reopen PowerShell, then run:
uv --versionMinimal Setup (Fastest Path)
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
uv python install 3.12
uv run pythonQuestions?
If you have any questions or run into any issues, please contact the lab assistant.