SetupPythonEnvironment.RdThis function validates the Python installation, checks for required modules, and installs dependencies if needed. It's designed to be called before any tcrClustR functions that rely on Python (e.g., RunTcrdist3, .FormatMetadata).
SetupPythonEnvironment(
pythonExecutable = NULL,
installMissing = TRUE,
useRequirementsTxt = TRUE,
verbose = TRUE
)Path to the Python executable. If NULL (default), will use reticulate::py_exe() or fall back to system Python3.
Logical. If TRUE (default), will attempt to install missing Python packages. If FALSE, will only validate and report missing packages.
Logical. If TRUE (default), will attempt to install dependencies from requirements.txt if available. If FALSE, will install individual packages.
Logical. If TRUE, will display detailed progress messages.
Invisible logical: TRUE if all dependencies are available, FALSE otherwise.
This function performs the following steps:
Validates Python executable exists and is functional
Checks for required Python modules: tcrdist3, pandas, numpy, rpy2
If installMissing=TRUE, installs missing packages via pip
Returns status of dependency availability
The function uses requirements.txt for dependency management when available, and falls back to individual package installation if not found.
if (FALSE) { # \dontrun{
# Check and install Python dependencies
SetupPythonEnvironment()
# Just validate without installing
SetupPythonEnvironment(installMissing = FALSE)
# Use specific Python executable
SetupPythonEnvironment(pythonExecutable = "/usr/bin/python3")
} # }