View source: R/22_SetupPyEnv.R
| SetupPyEnv.venv | R Documentation |
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.
## 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,
...
)
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. |
... |
Additional arguments. Currently supports:
|
Invisibly returns NULL.
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.
reticulate::virtualenv_create(), reticulate::virtualenv_remove(),
reticulate::use_virtualenv() for the underlying virtual environment
management functions.
## Not run:
# 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
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.