Learn about virtual environments and UV - the modern Python package manager.
•Isolated projects: Each project gets its own Python packages
•No conflicts: Different versions for different projects
•Easy sharing: Others can recreate your exact setup
All packages installed globally on your computer
Each project has its own isolated environment
Created by Astral, UV is a blazingly fast replacement for pip and virtualenv.
Read the official UV documentation↗Written in Rust for speed
Easier than pip + venv
Consistent installs every time
Why UV instead of pip? UV handles both Python installation AND package management in one tool. It's faster, simpler, and recommended for modern Python development.
Restart your terminal, then check:
UV uses a modern, simple workflow. Here are the commands you'll use:
Initialize a new Python project with a virtual environment
uv init my-project --python 3.12What happens: Creates a project folder with pyproject.toml (project config) and sets up a virtual environment with Python 3.12 automatically.
Important: Always use --python 3.12 for this course. Python 3.13 has compatibility issues with some data sources (Zenodo).
Add a package to your project (installs it automatically)
uv add jupyter numpy pandas matplotlib seabornWhat happens: Installs the package AND adds it to your pyproject.toml so others can recreate your setup.
Install all packages from an existing project
uv syncWhen to use: When you clone a project (like our course repo) that already has a pyproject.toml file. This installs everything needed.
Pro tip: When you open the project in Cursor IDE, it will automatically detect and use your virtual environment. No manual activation needed!
Here's what you'll do to set up the course notebooks:
This reads pyproject.toml and installs jupyter, numpy, pandas, matplotlib, biopython, etc.
Open the project folder in Cursor IDE:
Cursor will automatically detect your virtual environment and use it for running notebooks
Your environment is set up with all course packages. Cursor will handle the rest!
When you want to create your own Python project from scratch:
UV creates the project structure with Python 3.12, sets up the environment, and manages packages. Then open in Cursor to start coding!
•Cursor automatically detects your virtual environment - no manual activation needed!
•The .venv folder can be large (100s of MB) - don't commit it to Git
•Each project gets its own pyproject.toml file that tracks all dependencies
•Use uv add package-name to install new packages (not pip!)
That's it! UV manages your environment, and Cursor automatically uses it when you open notebooks.
Want to dive deeper into UV and Python package management?