useBasiliskEnv {basilisk} | R Documentation |
Use basilisk environments for isolated execution of Python code with appropriate versions of all Python packages.
useBasiliskEnv(envpath, dry = FALSE, required = TRUE)
envpath |
String containing the path to the environment to use. |
dry |
Logical scalar indicating whether only the directory should be returned without loading the environment. |
required |
Logical scalar indicating whether an error should be raised if the requested environment cannot be found. |
It is unlikely that developers should ever need to call useBasiliskEnv
directly.
Rather, this interaction should be automatically handled by basiliskStart
.
A side-effect of useBasiliskEnv
with dry=FALSE
is that the "PYTHONPATH"
environment variable is unset for the duration of the R session
(or basilisk process, depending on the back-end chosen by basiliskStart
).
This is a deliberate choice to avoid compromising the version guarantees if import
is allowed to search other locations beyond the specified environment.
The function will load the specified basilisk environment into the R session.
It returns a string specifying the path to the environment.
If dry=TRUE
, the character vector is returned without loading the environment.
Aaron Lun
basiliskStart
, for how these virtual environments should be used.
# This may return TRUE or FALSE, depending on the available Python. tmploc <- file.path(tempdir(), "my_package_B") setupBasiliskEnv(tmploc, 'pandas==0.25.1') useBasiliskEnv(tmploc, required=FALSE) # This will return FALSE, as the available Python is already set. baseloc <- basilisk.utils::getBasiliskDir() useBasiliskEnv(baseloc, required=FALSE)