The Inline Python Code for Quarto is not working in VS Code but the Inline R Code is! #9731
-
DescriptionHello, I am currently incredibly confused why my inline python code is not working, but my inline R code is working. Here is my code: This produces the following: Does anyone know why my python inline code isn't working? I have already checked whether Python executes. It does, but only within the python code block. Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 13 replies
-
The Python inline is for Jupyter (https://quarto.org/docs/computations/inline-code.html). I don't think knitr/reticulate even supports Python inline or any knitr engine/language other than R. |
Beta Was this translation helpful? Give feedback.
-
Let me be more precise on this affirmation. knitr supports any language that has a knitr's engine defined. Built-in or coming from other R packages. More on this in knitr docs
Regarding inline execution, it is a knitr specific feature to the R engine - so only However, some packages like reticulate offers interoperatibility, and so Python values can be accessed from R. This means you just have to leverage the R inline syntax. See https://rstudio.github.io/reticulate/articles/r_markdown.html ---
title: test
---
```{r}
library(reticulate)
```
```{python}
a = 5
```
The variable is `r py$a`
```{r}
b = 5
```
The variable is `r b`
I hope this helps understand how it works. |
Beta Was this translation helpful? Give feedback.
Let me be more precise on this affirmation.
knitr supports any language that has a knitr's engine defined. Built-in or coming from other R packages. More on this in knitr docs
Even a custom engine can be defined (https://bookdown.org/yihui/rmarkdown-cookbook/custom-engine.html)
python
engine for knitr is from reticulate R package: https://rstudio.github.io/reticulate/reference/eng_python.htmlRegarding inline execution, it is a knitr specific feature to the R e…