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/).