Reticulate

Positron has built-in support for Python interpreters managed by the reticulate R package. When the reticulate package is installed, you can use the repl_python() function to start a Python interpreter session directly within Positron. This allows you to run Python code interactively, exactly the same way as you would in a standard Python interpreter.

The feature is controlled by the positron.reticulate.enabled setting which is set to 'auto' by default. When 'auto' is selected, Positron’s reticulate integration will be enabled in workspaces where the reticulate R package has been loaded at least once. You can also explicitly enable or disable the reticulate integration by setting the value to 'always' or 'never', respectively.

To start a reticulate Python interpreter session, execute the following in an active R interpreter session:

reticulate::repl_python()

Reticulate Python interpreter session

The Reticulate Python interpreter can also be started by selecting “Python (reticulate)” when creating a new interpreter session.

New interpreter session list

Python interpreters managed by the reticulate package have some important differences compared to standard Python interpreters:

The latter has a few important implications:

Accessing R objects in Python

Note that for the above, the conversion between R and Python objects is managed by reticulate using the py_to_r() and r_to_py() generics. See the type conversions table for more information.

The reticulate Python interpreter session is tied to the lifecycle of its parent R session. If you close the parent R session or restart it, the Python interpreter session will also be terminated. It’s possible to restart the Python interpreter session independently, but note that this will not restart the associated R session.