Why is a Quarto trying to run Python when I render a document with Stan code chunk?

I am trying to render a Quarto document with a Stan code chunk. But when I do, a .ipynb file pops up in my directory and I get an error message about a missing Python library

Starting python3 kernel...Traceback (most recent call last):
  File "/Applications/RStudio.app/Contents/Resources/app/quarto/share/jupyter/jupyter.py", line 21, in <module>
    from notebook import notebook_execute, RestartKernel
  File "/Applications/RStudio.app/Contents/Resources/app/quarto/share/jupyter/notebook.py", line 18, in <module>
    from nbclient import NotebookClient
ModuleNotFoundError: No module named 'nbclient'

All I would like is for the Stan code chunk to show up in the rendered output. Here is an example .qmd file I am having this issue with:

---
title: "Untitled"
format: html
---

```{stan}
data {
  int<lower=1> N;    
  array[N] real x;
  array[N] real y;
}

parameters {
  real beta0;           
  real beta1;
  real sigma;
}

model {
  y ~ normal(beta0 + beta1 * x, sigma);
}

Sorry for the delay.

This a matter of Automatic binding for computations Engine - See doc : Quarto - Execution Options

R and knitr engine will only be used if there is at least R chunk. You have none in your doc but you are still trying to use knitr so you need to be explicit. Add

engine: knitr

in the YAML header

---
title: "Untitled"
format: html
engine: knitr
---

```{stan}
data {
  int<lower=1> N;    
  array[N] real x;
  array[N] real y;
}

parameters {
  real beta0;           
  real beta1;
  real sigma;
}

model {
  y ~ normal(beta0 + beta1 * x, sigma);
}
```

Hope it clarifies

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.