Skip to content

Using reticulate in VSCode when dynamically executing quarto document #2313

@psl-schaefer

Description

@psl-schaefer

Bug description

I have simple Quarto document with one R and one Python chunk. I want to access R variables in the python chunk via reticulate (reticulate::repl_python()) which works fine when I work with the document in RStudio.

---
title: "Example"
format: html
engine: knitr
---
# r chunk
library(reticulate)
data(cars)
# python chunk
car_df=r.cars
car_df

However, when I am using VSCode it doesn't work anymore. When I execute the python chunk, a Python REPL is started that has nothing to do with the R Session. Thus, I get a NameError in the python chunk because name 'r' is not defined.

Am I using the wrong settings in VSCode? Why isn't the Python REPL started via reticulate::repl_python() as it is in RStudio? Funnily, if I knit the Quarto document in VSCode everything is working fine. It might be important that I am working over an SSH connection in VSCode.

I know that I could simply type in the R console reticulate::repl_python(), but it would be much more convenient if VSCode would "automatically" use the correct repl.

Version Info

RStudio Server Version: 2022.07.1+554
VSCode Version: Version: 1.71.0
OS: Ubuntu 20.04.5 LTS (Focal Fossa)

Checklist

  • Please include a minimal, fully reproducible example in a single .qmd file? Please provide the whole file rather than the snippet you believe is causing the issue.
  • Please format your issue so it is easier for us to read the bug report.
  • Please document the RStudio IDE version you're running (if applicable), by providing the value displayed in the "About RStudio" main menu dialog?
  • Please document the operating system you're running. If on Linux, please provide the specific distribution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions