[UV](https://docs.astral.sh/uv/) is a fast new [[Python]] [[virtual environment]] and package manager by the developers of [[Rust]]. It is considerably faster than [[mamba]] and offers many of the advanced features of [[Poetry]] like lock files for better environment reproducibility across workstations. Instead of activating an environment as usual, all you need to do is be within the project directory to have the same effect. ## install on WSL To install on [[Windows Subsystem for Linux|WSL]], open your Ubuntu terminal and use command ```bash curl -LsSf https://astral.sh/uv/install.sh | sh ``` To confirm installation, use ```bash uv -V ``` ## initialize an environment Use `uv` to create a project in your `projects` directory with ```bash uv init <my-project> ``` or initialize `uv` within an existing project with ```bash uv init ``` ## add a dependency To add a dependency use ```bash uv add <package> ``` From a [[requirements.txt]] file use ```bash uv add -r requirements.txt ``` ## list dependencies To list dependencies, use ```bash uv pip list ``` ## run a script Running scripts with `uv` is a little different than in other package managers like conda. You don't need to activate an environment provide you are executing a script from within a project (i.e., a directory with `pyproject.toml` file included). ```bash uv run <script.py> ``` ## with Jupyter Notebook To use [[Jupyter Notebook]] with `uv` simply use ```bash uv run --with jupyter jupyter lab ``` This will install and launch Jupyter Lab with your dependencies accessible for import. You don't even need to install Jupyter beforehand! One of the most unique features of uv is its ability to create virtual environments automatically when you run a script from within a project directory. To run notebooks in [[VS Code]], add [[iPython kernel]] ```bash uv add ipykernel ```