From d77598a08ca230350d1023c8e0e3f0cfcd85e704 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Thu, 9 Jan 2025 16:43:09 -0500 Subject: [PATCH] Use Windows-specific instructions in Jupyter guide (#10446) ## Summary Closes https://github.com/astral-sh/uv/issues/10407. --- docs/guides/integration/jupyter.md | 28 +++++++++++++++++++++------- docs/guides/projects.md | 23 +++++++++++++++++------ 2 files changed, 38 insertions(+), 13 deletions(-) diff --git a/docs/guides/integration/jupyter.md b/docs/guides/integration/jupyter.md index f1292a581..a81890287 100644 --- a/docs/guides/integration/jupyter.md +++ b/docs/guides/integration/jupyter.md @@ -106,12 +106,23 @@ If you need to run Jupyter in a virtual environment that isn't associated with a [project](../../concepts/projects/index.md) (e.g., has no `pyproject.toml` or `uv.lock`), you can do so by adding Jupyter to the environment directly. For example: -```console -$ uv venv --seed -$ uv pip install pydantic -$ uv pip install jupyterlab -$ .venv/bin/jupyter lab -``` +=== "macOS and Linux" + + ```console + $ uv venv --seed + $ uv pip install pydantic + $ uv pip install jupyterlab + $ .venv/bin/jupyter lab + ``` + +=== "Windows" + + ```powershell + uv venv --seed + uv pip install pydantic + uv pip install jupyterlab + .venv\Scripts\jupyter lab + ``` From here, `import pydantic` will work within the notebook, and you can install additional packages via `!uv pip install`, or even `!pip install`. @@ -125,10 +136,13 @@ project, as in the following: ```console # Create a project. $ uv init project + # Move into the project directory. $ cd project + # Add ipykernel as a dev dependency. $ uv add --dev ipykernel + # Open the project in VS Code. $ code . ``` @@ -136,7 +150,7 @@ $ code . Once the project directory is open in VS Code, you can create a new Jupyter notebook by selecting "Create: New Jupyter Notebook" from the command palette. When prompted to select a kernel, choose "Python Environments" and select the virtual environment you created earlier (e.g., -`.venv/bin/python`). +`.venv/bin/python` on macOS and Linux, or `.venv\Scripts\python` on Windows). !!! note diff --git a/docs/guides/projects.md b/docs/guides/projects.md index 867a25238..a9d219162 100644 --- a/docs/guides/projects.md +++ b/docs/guides/projects.md @@ -177,12 +177,23 @@ $ uv run example.py Alternatively, you can use `uv sync` to manually update the environment then activate it before executing a command: -```console -$ uv sync -$ source .venv/bin/activate -$ flask run -p 3000 -$ python example.py -``` +=== "macOS and Linux" + + ```console + $ uv sync + $ source .venv/bin/activate + $ flask run -p 3000 + $ python example.py + ``` + +=== "Windows" + + ```powershell + uv sync + source .venv\Scripts\activate + flask run -p 3000 + python example.py + ``` !!! note