Home Explore Blog CI



zed

2nd chunk of `docs/src/repl.md`
5b9737c8efd2bf15864074cf0583a66bbe7e595cd34b207d0000000100000846
Zed supports [notebooks as scripts](https://jupytext.readthedocs.io/en/latest/formats-scripts.html) using the `# %%` cell separator in Python and `// %%` in TypeScript. This allows you to write code in a single file and run it as if it were a notebook, cell by cell.

The `repl: run` command will run each block of code between the `# %%` markers as a separate cell.

```python
# %% Cell 1
import time
import numpy as np

# %% Cell 2
import matplotlib.pyplot as plt
import matplotlib.pyplot as plt
from matplotlib import style
style.use('ggplot')
```

## Language specific instructions

### Python {#python}

#### Global environment

<div class="warning">

On macOS, your system Python will _not_ work. Either set up [pyenv](https://github.com/pyenv/pyenv?tab=readme-ov-file#installation) or use a virtual environment.

</div>

To setup your current Python to have an available kernel, run:

```sh
pip install ipykernel
python -m ipykernel install --user
```

#### Conda Environment

```sh
source activate myenv
conda install ipykernel
python -m ipykernel install --user --name myenv --display-name "Python (myenv)"
```

#### Virtualenv with pip

```sh
source activate myenv
pip install ipykernel
python -m ipykernel install --user --name myenv --display-name "Python (myenv)"
```

### R (Ark Kernel) {#r-ark}

Install [Ark](https://github.com/posit-dev/ark/releases) by downloading the release for your operating system. For example, for macOS just unpack `ark` binary and put it into `/usr/local/bin`. Then run:

```sh
ark --install
```

### R (Xeus Kernel) {#r-xeus}

- Install [Xeus-R](https://github.com/jupyter-xeus/xeus-r)
- Install the R Extension for Zed (search for `R` in Zed Extensions)

<!--
TBD: Improve R REPL (Ark Kernel) instructions
-->

### Typescript: Deno {#typescript-deno}

- [Install Deno](https://docs.deno.com/runtime/manual/getting_started/installation/) and then install the Deno jupyter kernel:

```sh
deno jupyter --install
```

<!--
TBD: Improve R REPL (Ark Kernel) instructions
-->

### Julia

- Download and install Julia from the [official website](https://julialang.org/downloads/).

Title: Zed REPL: Language-Specific Instructions (Python, R, TypeScript, Julia)
Summary
This section provides language-specific instructions for setting up and using the Zed REPL. It covers Python (with global, Conda, and virtualenv environments, including a warning about macOS system Python), R (using both Ark and Xeus kernels), TypeScript (using Deno), and Julia. Instructions include installing necessary packages, kernels, and extensions for each language to enable REPL functionality within Zed.