Installing extras: cu.install

colabutilscs4337.install(*targets, allow_changes=False, upgrade=False, dry=False, verbose=True, backend='auto')[source]

Install extras ("cam", "fastai", "all") or any requirement strings.

Every already-installed package is pinned to its current version, so this only ever adds packages. If that is impossible, nothing is installed and InstallError explains why. allow_changes=True lifts the pins. dry=True reports what would happen without installing.

backend="auto" uses uv when it is installed (it is in Colab) and pip otherwise; if uv fails, pip is tried. upgrade=True upgrades only the requested packages, never their dependencies.

Examples

>>> cu.install("cam")                    # Grad-CAM++ and friends
>>> cu.install("torchmetrics", dry=True)         # preview: what would be added?
>>> cu.install("torchmetrics", upgrade=True)     # newer torchmetrics only
>>> cu.install("torchmetrics", backend="pip")    # force pip
Parameters:
  • targets (str)

  • allow_changes (bool)

  • upgrade (bool)

  • dry (bool)

  • verbose (bool)

  • backend (str)

Return type:

InstallResult

class colabutilscs4337._install.InstallResult(requested: 'list[str]', added: 'dict[str, str]', changed: 'dict[str, tuple[str, str]]', new_problems: 'list[str]', restart_needed: 'bool', backend: 'str' = 'pip')[source]

Bases: object

Parameters:
  • requested (list[str])

  • added (dict[str, str])

  • changed (dict[str, tuple[str, str]])

  • new_problems (list[str])

  • restart_needed (bool)

  • backend (str)

exception colabutilscs4337._install.InstallError[source]

Bases: RuntimeError

exception colabutilscs4337._install.UnresolvableError[source]

Bases: InstallError

The request cannot be satisfied (with the current pins); retrying will not help.