View source: R/22_SetupPyEnv.R
| SetupPyEnv | R Documentation |
Sets up a Python environment with specified packages. This function can create new environments or reuse existing ones, supporting both Conda and venv environment types. It ensures all required dependencies are properly installed and verified.
Default method for unsupported environment types. Throws an informative error with supported environment types.
SetupPyEnv(env_type = c("conda", "venv"), ...)
## Default S3 method:
SetupPyEnv(env_type = c("conda", "venv"), ...)
env_type |
Character string specifying the type of Python environment to
create or use. One of: |
... |
Additional parameters passed to specific environment methods. |
This function provides a comprehensive solution for Python environment management in R projects, particularly for machine learning workflows requiring TensorFlow. Key features include:
Environment Creation: Automatically creates new environments or reuses existing ones with the same name
Package Management: Installs specified Python packages with version pinning support
Verification: Validates environment setup and package installations
Flexible Methods: Supports different backend methods for environment creation (reticulate vs system calls)
The function uses S3 method dispatch to handle different environment types, allowing for extensible support of additional environment managers in the future.
A data frame containing verification results for the environment setup, including installation status of all required packages. Invisibly returns the verification results.
reticulate::conda_create(), reticulate::virtualenv_create() for
underlying environment creation functions.
## Not run:
# Setup a Conda environment with default parameters
SetupPyEnv("conda")
# Setup a venv environment
SetupPyEnv("venv")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.