quarto-dev / quarto

Quarto open-source scientific and technical publishing system
https://quarto.org
GNU Affero General Public License v3.0
315 stars 26 forks source link

Choose R kernel in VS Code #358

Closed royfrancis closed 8 months ago

royfrancis commented 8 months ago

In VS Code, When an ipynb notebook is opened, there is an option in the top right to choose the Python kernal. This gives me the flexibility to choose from the various virtual environments and conda environments that I have.

Screenshot 2024-01-17 at 18 16 44

How do I choose which Python or R to use in a quarto document?

VS Code 1.85.1
Quarto extension: v1.110.1
jjallaire commented 8 months ago

If you use the Python: Select Interpreter command (which sets the default Python for the current workspace) then Quarto will follow the version of Python specified there.

mcanouil commented 7 months ago

Additionally, one can use _environment (https://quarto.org/docs/projects/environment.html):

QUARTO_PYTHON=/path/to/bin
QUARTO_R=/path/to/bin
royfrancis commented 6 months ago

I assume you are talking about rendering a quarto document in the terminal. I was asking about interactively working in a quarto document in VS Code using the quarto extension.

At the moment, for local use I enter the conda environment through the terminal and then launch VS Code from there and everything seems to work. But that doesn't work with remote hosts when using VS Code extension Remotes. For that to work I need to manually go into the VS Code R extension settings and set Rpath and Rterm to the R path inside the conda env. This is so impractical. That's why I brought up the Jupyter notebook example where they have the 'Select Kernal' button which makes this all so much easier.