Skip to contents

This function explicitly initializes a Python session in the current R session. A single R session can only be bound to one Python session. Once initialized, the Python configuration is fixed for the duration of the R session.

Usage

py_init(python_path = reticulate::py_discover_config()$python, quiet = FALSE)

Arguments

python_path

Character. Path to the Python executable to use. Defaults to the python element returned by reticulate::py_discover_config().

quiet

Boolean. Whether to suppress message.

Value

An invisible Python configuration object, as returned by reticulate::py_config().

Details

If Python has already been initialized, a warning is issued and the existing configuration is returned. Otherwise, the specified Python executable is used to start a new session.

Examples

if (FALSE) { # \dontrun{
# Initialize Python using the default discovery
py_init()
} # }