Skip to contents

Creates and configures a Python virtual environment (venv) specifically designed for screening workflows. This function provides a lightweight, isolated Python environment alternative to Conda environments with similar package management capabilities.

Usage

# S3 method for class 'venv'
SetupPyEnv(
  env_type = "venv",
  env_name = "r-reticulate-degas",
  python_version = "3.9.15",
  packages = c(tensorflow = "2.4.1", protobuf = "3.20.3"),
  python_path = NULL,
  recreate = FALSE,
  verbose = TRUE,
  ...
)

Arguments

env_type

Character string specifying the environment type. For this method, must be "venv".

env_name

Character string specifying the virtual environment name. Default: "r-reticulate-degas".

python_version

Character string specifying the Python version to use. Default: "3.9.15".

packages

Named character vector of Python packages to install. Package names as names, versions as values. Use "any" for version to install latest available. Default includes tensorflow, protobuf, and numpy.

python_path

Character string specifying the path to a specific Python executable. If NULL, uses the system default or installs the specified version. Default: NULL.

recreate

Logical indicating whether to force recreation of the virtual environment if it already exists. Default: FALSE.

verbose

Logical indicating whether to display detailed progress messages and command output. Default: TRUE.

...

For future compatibility.

Value

Invisibly returns NULL.

Note

Virtual environments require a base Python installation. If the specified Python version is not available, the function will attempt to install it using reticulate. Virtual environments are generally faster to create than Conda environments but may have more limited package availability compared to Conda-forge.

See also

reticulate::virtualenv_create(), reticulate::virtualenv_remove(), reticulate::use_virtualenv() for the underlying virtual environment management functions.

Examples

if (FALSE) { # \dontrun{
# Setup virtual environment with default parameters
SetupPyEnv.venv()

# Setup with custom Python version and packages
SetupPyEnv.venv(
  env_name = "my-degas-venv",
  python_version = "3.8.12",
  packages = c(
    "tensorflow" = "2.4.1",
    "scikit-learn" = "1.0.2",
    "pandas" = "any"
  )
)

# Force recreate existing environment
SetupPyEnv.venv(
  env_name = "existing-env",
  recreate = TRUE
)
} # }