require(reqs=None, *args, message=None, exact=False, detailed=False, die=True, warn=True, verbose=True, **kwargs)[source]#

Check whether environment requirements are met. Alias to pkg_resources.require().

  • reqs (list/dict) – a list of strings, or a dict of package names and versions

  • args (list) – additional requirements

  • message (str) – optionally provide a custom error message if requirements are not met; “<MISSING>” will be replaced with list of missing requirements

  • kwargs (dict) – additional requirements

  • exact (bool) – use ‘==’ instead of ‘>=’ as the default comparison operator if not specified

  • detailed (bool) – return a dict of which requirements are/aren’t met

  • die (bool) – whether to raise an exception if requirements aren’t met

  • warn (bool) – if not die, raise a warning if requirements aren’t met

  • verbose (bool) – print out the exception if it’s not being raised or warned


sc.require(reqs={'numpy':'1.19.1', 'matplotlib':'3.2.2'})
sc.require('numpy>=1.19.1', 'matplotlib==3.2.2', die=False, message='Requirements <MISSING> not met, but continuing anyway')
sc.require(numpy='1.19.1', matplotlib='==4.2.2', die=False, detailed=True)
New in version 1.2.2.
New in version 3.0.0: “warn” argument
New in version 3.1.3: “message” argument
New in version 3.1.6: replace pkg_resources dependency with packaging