Micropip API
Micropip API#
- micropip.install(requirements: str | list[str], keep_going: bool = False)#
Install the given package and all of its dependencies.
See loading packages for more information.
This only works for packages that are either pure Python or for packages with C extensions that are built in Pyodide. If a pure Python package is not found in the Pyodide repository it will be loaded from PyPI.
When used in web browsers, downloads from PyPI will be cached. When run in Node.js, packages are currently not cached, and will be re-downloaded each time
micropip.install
is run.- Parameters
requirements (
str | List[str]
) –A requirement or list of requirements to install. Each requirement is a string, which should be either a package name or URL to a wheel:
If the requirement ends in
.whl
it will be interpreted as a URL. The file must be a wheel named in compliance with the PEP 427 naming convention.If the requirement does not end in
.whl
, it will interpreted as the name of a package. A package by this name must either be present in the Pyodide repository at indexURL <globalThis.loadPyodide> or on PyPI
keep_going (
bool
, default: False) –This parameter decides the behavior of the micropip when it encounters a Python package without a pure Python wheel while doing dependency resolution:
If
False
, an error will be raised on first package with a missing wheel.If
True
, the micropip will keep going after the first error, and report a list of errors at the end.
- Returns
A
Future
that resolves toNone
when all packages have been downloaded and installed.- Return type
Future
- micropip.list()#
Get the dictionary of installed packages.
- Returns
packages – A dictionary of installed packages.
>>> import micropip >>> await micropip.install('regex') >>> package_list = micropip.list() >>> print(package_list) Name | Version | Source ----------------- | -------- | ------- regex | 2021.7.6 | pyodide >>> "regex" in package_list True
- Return type
- class package.PackageDict(dict=None, /, **kwargs)#
A dictionary that holds list of metadata on packages. This class is used in micropip to keep the list of installed packages.