install_package()

audeer.install_package(name, *, version=None, silent=False)[source]

Install a Python package with pip.

An error is raised if a different version of the package is already installed. However, it is possible to use one of the following operators in front of the version string: '>=', '>', '<=', '<'. In that case, an error is raised only if the condition is not satisfied. If version is set to None and the package is not installed yet, the latest version will be installed.

Parameters
  • name (str) – package name

  • version (Optional[str]) – version string (see description)

  • silent (bool) – suppress messages to stdout

Raises
  • subprocess.CalledProcessError – if the sub-process calling pip fails, e.g. because requested version of the package is not found

  • RuntimeError – if a version of the package is already installed that does not satisfy the requested version