% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/useBasiliskEnv.R
\name{useBasiliskEnv}
\alias{useBasiliskEnv}
\title{Use \pkg{basilisk} environments}
\usage{
useBasiliskEnv(envpath, full.activation = NA)
}
\arguments{
\item{envpath}{String containing the path to the \pkg{basilisk} environment to use.}

\item{full.activation}{Logical scalar, see \code{\link{activateEnvironment}} for details.}
}
\value{
The function will attempt to load the specified \pkg{basilisk} environment into the R session,
possibly with the modification of some environment variables (see Details).
A \code{NULL} is invisibly returned.
}
\description{
Use \pkg{basilisk} environments for isolated execution of Python code with appropriate versions of all Python packages.
}
\details{
It is unlikely that developers should ever need to call \code{\link{useBasiliskEnv}} directly.
Rather, this interaction should be automatically handled by \code{\link{basiliskStart}}.

This function will modify a suite of environment variables as a side effect
- see \dQuote{Persistence of environment variables} in \code{?\link{basiliskStart}} for the rationale.
}
\examples{
\dontshow{basilisk.utils::installConda()}

tmploc <- file.path(tempdir(), "my_package_A")
if (!file.exists(tmploc)) {
    setupBasiliskEnv(tmploc, c('pandas==1.4.3'))
}

# This may or may not work, depending on whether a Python instance
# has already been loaded into this R session.
try(useBasiliskEnv(tmploc))

# This will definitely not work, as the available Python is already set.
baseloc <- basilisk.utils::getCondaDir()
status <- try(useBasiliskEnv(baseloc))

# ... except on Windows, which somehow avoids tripping the error.
stopifnot(is(status, "try-error") || basilisk.utils::isWindows())

}
\seealso{
\code{\link{basiliskStart}}, for how these \pkg{basilisk} environments should be used.
}
\author{
Aaron Lun
}
