Note: This function is maintained for backward compatibility.
For new code, use attach_mosaic_env instead.
Switches the current R session to use the MOSAIC Python environment at ~/.virtualenvs/r-mosaic. This function attempts to switch from other Python environments (like r-keras) to the MOSAIC environment.
Details
This function attempts to switch the Python environment mid-session. Due to reticulate limitations, if Python has already been initialized with a different environment, a complete switch may require restarting R. The function will provide appropriate guidance based on the current state.
Recommended: Use attach_mosaic_env for clearer semantics
and better error handling. Loading MOSAIC does not attach Python: it only
sets RETICULATE_PYTHON to r-mosaic (when unset), so reticulate binds r-mosaic
on the first Python call.
See also
attach_mosaic_env for the recommended function,
detach_mosaic_env for detaching the environment,
check_python_env for checking the current environment,
check_dependencies for verifying the setup,
install_dependencies for installing the environment
Examples
if (FALSE) { # \dontrun{
# Old approach (still works)
use_mosaic_env()
# New approach (recommended)
attach_mosaic_env()
# Loading MOSAIC points reticulate at r-mosaic; Python starts lazily
library(MOSAIC)
} # }
