Skip to content
Prev 393681 / 398503 Next

Problem to run python code in r markdown

You don't specify what platform you are on (linux / Windows / other),
and what tools you are using.
I am running a linux system and I have virtual environments set up.
I set the environment variable RETICULATE_PYTHON to point to python
(in my virtual environment).
I am using RStudio, and I use the File pulldown menu and select New
File --> 'R Markdown' or New File --> 'Quarto document'.
In the R Markdown (or Quarto) document, create a python code chunk:

```{python}
import numpy as np
print(np.arange(5))
```

works for me.
HTH,
Eric




On Fri, Jan 20, 2023 at 6:20 PM Kai Yang via R-help
<r-help at r-project.org> wrote: