Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add JupyterLab integration docs #1147

Merged
merged 4 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions docs/ide_integration/jupyterlab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
part: pixi/ide_integration
title: JupyterLab Integration
description: Use JupyterLab with pixi environments
---

## Basic usage

Using JupyterLab with pixi is very simple.
You can just create a new pixi project and add the `jupyterlab` package to it.
The full example is provided under the following [Github link](https://github.com/prefix-dev/pixi/tree/main/examples/jupyterlab).

```bash
pixi init
pixi add jupyterlab
```

This will create a new pixi project and add the `jupyterlab` package to it. You can then start JupyterLab using the
following command:

```bash
pixi run jupyter lab
```

If you want to add more "kernels" to JupyterLab, you can simply add them to your current project – as well as any dependencies from the scientific stack you might need.

```bash
pixi add bash_kernel ipywidgets matplotlib numpy pandas # ...
```

### What kernels are available?

You can easily install more "kernels" for JupyterLab. The `conda-forge` repository has a number of interesting additional kernels - not just Python!

- [**`bash_kernel`**](https://prefix.dev/channels/conda-forge/packages/bash_kernel) A kernel for bash
- [**`xeus-cpp`**](https://prefix.dev/channels/conda-forge/packages/xeus-cpp) A C++ kernel based on the new clang-repl
- [**`xeus-cling`**](https://prefix.dev/channels/conda-forge/packages/xeus-cling) A C++ kernel based on the slightly older Cling
- [**`xeus-lua`**](https://prefix.dev/channels/conda-forge/packages/xeus-lua) A Lua kernel
- [**`xeus-sql`**](https://prefix.dev/channels/conda-forge/packages/xeus-sql) A kernel for SQL
- [**`r-irkernel`**](https://prefix.dev/channels/conda-forge/packages/r-irkernel) An R kernel

## Advanced usage

<!--
Modifications to the following section are related to the README.md in https://github.com/renan-r-santos/pixi-kernel and
https://github.com/renan-r-santos/pixi-kernel-binder, please keep these two in sync by making a PR in both
-->

If you want to have only one instance of JupyterLab running but still want per-directory Pixi environments, you can use
one of the kernels provided by the [**`pixi-kernel`**](https://prefix.dev/channels/conda-forge/packages/pixi-kernel)
package.

### Configuring JupyterLab

To get started, create a Pixi project, add `jupyterlab` and `pixi-kernel` and then start JupyterLab:

```bash
pixi init
pixi add jupyterlab pixi-kernel
pixi run jupyter lab
```

This will start JupyterLab and open it in your browser.

![JupyterLab launcher screen showing Pixi
Kernel](https://raw.githubusercontent.com/renan-r-santos/pixi-kernel/main/assets/launch-light.png#only-light)
![JupyterLab launcher screen showing Pixi
Kernel](https://raw.githubusercontent.com/renan-r-santos/pixi-kernel/main/assets/launch-dark.png#only-dark)

`pixi-kernel` searches for a manifest file, either `pixi.toml` or `pyproject.toml`, in the same directory of your
notebook or in any parent directory. When it finds one, it will use the environment specified in the manifest file to
start the kernel and run your notebooks.

### Binder

If you just want to check a JupyterLab environment running in the cloud using `pixi-kernel`, you can visit
[Binder](https://mybinder.org/v2/gh/renan-r-santos/pixi-kernel-binder/main?labpath=example.ipynb).
2 changes: 1 addition & 1 deletion docs/stylesheets/extra.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

[data-md-color-accent=prefix-light] {
--md-accent-fg-color: #2e2400;
--md-accent2-fg-color: #eab308;
--md-accent2-fg-color: #19116f;
--md-accent-fg-color--transparent: #ffaa001a;
--md-accent-bg-color: #000000de;
--md-accent-bg-color--light: #0000008a
Expand Down
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ nav:
- Installation: index.md
- Basic Usage: basic_usage.md
- IDE Integration:
- JupyterLab: ide_integration/jupyterlab.md
- PyCharm: ide_integration/pycharm.md
- RStudio: ide_integration/r_studio.md
- Tutorials:
Expand Down
Loading