Use Windows-specific instructions in Jupyter guide (#10446)

## Summary

Closes https://github.com/astral-sh/uv/issues/10407.
This commit is contained in:
Charlie Marsh 2025-01-09 16:43:09 -05:00 committed by GitHub
parent 7096e83812
commit d77598a08c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 38 additions and 13 deletions

View file

@ -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

View file

@ -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