Skip to contents

Check and install python packages

Usage

check_python(
  packages,
  envname = NULL,
  conda = "auto",
  force = FALSE,
  pip = TRUE,
  pip_options = character(),
  verbose = TRUE,
  ...
)

Arguments

packages

A character vector, indicating package names which should be installed or removed. Use "<package>==<version>" to request the installation of a specific version of a package.

envname

The name of a conda environment.

conda

The path to a conda executable. Use "auto" to allow scop to automatically find an appropriate conda binary.

force

Whether to force package installation. Default is FALSE.

pip

Whether to use pip for package installation. Default is TRUE, packages are installed from the active conda channels.

pip_options

An optional character vector of additional command line arguments to be passed to pip. Only relevant when pip = TRUE.

verbose

Whether to print the message. Default is TRUE.

...

Other arguments passed to reticulate::conda_install

Examples

check_python(
  packages = c("numpy", "pandas")
)
#>  [2025-09-20 14:01:53] Checking 2 packages in environment: scop_env
#>  [2025-09-20 14:01:54] Retrieving package list for environment: scop_env
#>  [2025-09-20 14:01:56] Found 197 packages installed
#>  [2025-09-20 14:01:56] numpy version: 1.26.4
#>  [2025-09-20 14:01:57] pandas version: 2.0.3

if (FALSE) { # \dontrun{
check_python(
  packages = "numpy==1.26.4",
  envname = "scop_env",
  pip_options = "-i https://pypi.tuna.tsinghua.edu.cn/simple"
)
} # }