mirror of https://github.com/astral-sh/uv
Use Windows-specific instructions in Jupyter guide (#10446)
## Summary Closes https://github.com/astral-sh/uv/issues/10407.
This commit is contained in:
parent
7096e83812
commit
d77598a08c
|
|
@ -106,6 +106,8 @@ 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
|
[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:
|
so by adding Jupyter to the environment directly. For example:
|
||||||
|
|
||||||
|
=== "macOS and Linux"
|
||||||
|
|
||||||
```console
|
```console
|
||||||
$ uv venv --seed
|
$ uv venv --seed
|
||||||
$ uv pip install pydantic
|
$ uv pip install pydantic
|
||||||
|
|
@ -113,6 +115,15 @@ $ uv pip install jupyterlab
|
||||||
$ .venv/bin/jupyter lab
|
$ .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
|
From here, `import pydantic` will work within the notebook, and you can install additional packages
|
||||||
via `!uv pip install`, or even `!pip install`.
|
via `!uv pip install`, or even `!pip install`.
|
||||||
|
|
||||||
|
|
@ -125,10 +136,13 @@ project, as in the following:
|
||||||
```console
|
```console
|
||||||
# Create a project.
|
# Create a project.
|
||||||
$ uv init project
|
$ uv init project
|
||||||
|
|
||||||
# Move into the project directory.
|
# Move into the project directory.
|
||||||
$ cd project
|
$ cd project
|
||||||
|
|
||||||
# Add ipykernel as a dev dependency.
|
# Add ipykernel as a dev dependency.
|
||||||
$ uv add --dev ipykernel
|
$ uv add --dev ipykernel
|
||||||
|
|
||||||
# Open the project in VS Code.
|
# Open the project in VS Code.
|
||||||
$ 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
|
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
|
"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.,
|
"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
|
!!! note
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -177,6 +177,8 @@ $ uv run example.py
|
||||||
Alternatively, you can use `uv sync` to manually update the environment then activate it before
|
Alternatively, you can use `uv sync` to manually update the environment then activate it before
|
||||||
executing a command:
|
executing a command:
|
||||||
|
|
||||||
|
=== "macOS and Linux"
|
||||||
|
|
||||||
```console
|
```console
|
||||||
$ uv sync
|
$ uv sync
|
||||||
$ source .venv/bin/activate
|
$ source .venv/bin/activate
|
||||||
|
|
@ -184,6 +186,15 @@ $ flask run -p 3000
|
||||||
$ python example.py
|
$ python example.py
|
||||||
```
|
```
|
||||||
|
|
||||||
|
=== "Windows"
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
uv sync
|
||||||
|
source .venv\Scripts\activate
|
||||||
|
flask run -p 3000
|
||||||
|
python example.py
|
||||||
|
```
|
||||||
|
|
||||||
!!! note
|
!!! note
|
||||||
|
|
||||||
The virtual environment must be active to run scripts and commands in the project without `uv run`. Virtual environment activation differs per shell and platform.
|
The virtual environment must be active to run scripts and commands in the project without `uv run`. Virtual environment activation differs per shell and platform.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue