useBasiliskEnv {basilisk}R Documentation

Use basilisk environments

Description

Use basilisk environments for isolated execution of Python code with appropriate versions of all Python packages.

Usage

useBasiliskEnv(envpath, dry = FALSE, required = TRUE)

Arguments

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.

Details

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.

Value

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.

Author(s)

Aaron Lun

See Also

basiliskStart, for how these virtual environments should be used.

Examples

# 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)


[Package basilisk version 0.99.60 Index]