R/pythonModulesCheck.R

Defines functions pythonModulesCheck

Documented in pythonModulesCheck

#' Python Modules Check
#'
#' Check to see if required Python modules are installed and if not, send an error message.
#' @keywords reticulate
#' @export
#' @examples
#' pythonModulesCheck()

pythonModulesCheck <- function() {
  
  missingModuleStopper <- function(module_name) {
    if (!reticulate::py_module_available(module_name)) {
      stop(paste0("The ", module_name, " Python package is not installed. Install it using cmd: 'pip install ", module_name, "'"))
    }
  }
  
  pythonModuleList <- list(
    "pandas",
    "re",
    "spacy",
    "rank_bm25",
    "tqdm",
    "pickle",
    "numpy",
    "gensim",
    "os",
    "nmslib",
    "time")

  lapply(pythonModuleList, missingModuleStopper)
}
harryahlas/bescea documentation built on July 3, 2022, 7:13 p.m.