Python environments: uv

satya - 6/29/2025, 8:38:36 AM

is there a diff between creating a python venv through venv or uv venv?

is there a diff between creating a python venv through venv or uv venv?

Search for: is there a diff between creating a python venv through venv or uv venv?

satya - 6/29/2025, 8:45:18 AM

My github write up on venv

My github write up on venv

satya - 6/29/2025, 8:47:29 AM

My github article: previous notes on uv

My github article: previous notes on uv

satya - 6/29/2025, 9:36:14 AM

uv venv equivalence



uv venv

//is equivalent to

python -m venv .venv

//Creates a sub directory .venv

satya - 6/29/2025, 9:37:26 AM

The -m means

  1. python a.py
  2. //runs a file anywhere in python path
  3. python -m a
  4. //runs a module in the available modules

satya - 6/29/2025, 10:02:36 AM

uv run a.py behavior

  1. if .venv exists, uses it as the dependency resolver cache
  2. if project.toml exists, resolves by installing dependencies into the .venv
  3. similar to uv pip install
  4. creates a uv.lock file in the process
  5. then runs the a.py

satya - 6/29/2025, 10:03:38 AM

In other words you can do this


//create a .venv for keeping vscode happy
uv venv

//ensure there is a project.toml and run your .py file
uv run a.py