API Reference#

async micropip.install(requirements, keep_going=False, deps=True, credentials=None, pre=False)#

Install the given package and all of its dependencies.

If a package is not found in the Pyodide repository it will be loaded from PyPI. Micropip can only load pure Python wheels or wasm32/emscripten wheels built by Pyodide.

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.

  • 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 a wheel URI:

    • If the requirement does not end in .whl, it will be interpreted as a package name. A package with this name must either be present in the Pyodide lock file or on PyPI.

    • If the requirement ends in .whl, it is a wheel URI. The part of the requirement after the last / must be a valid wheel name in compliance with the PEP 427 naming convention.

    • If a wheel URI starts with emfs:, it will be interpreted as a path in the Emscripten file system (Pyodide’s file system). E.g., emfs:../relative/path/wheel.whl or emfs:/absolute/path/wheel.whl. In this case, only .whl files are supported.

    • If a wheel URI requirement starts with http: or https: it will be interpreted as a URL.

    • In node, you can access the native file system using a URI that starts with file:. In the browser this will not work.

  • keep_going (bool) –

    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.

  • deps (bool) – If True, install dependencies specified in METADATA file for each package. Otherwise do not install dependencies.

  • credentials (Optional[str]) –

    This parameter specifies the value of credentials when calling the fetch() function which is used to download the package.

    When not specified, fetch() is called without credentials.

  • pre (bool) – If True, include pre-release and development versions. By default, micropip only finds stable versions.

Return type:



Get the dictionary of installed 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 

Return type:



Produce a json string which can be used as the contents of the repodata.json lock file.

If you later load Pyodide with this lock file, you can use pyodide.loadPackage() to load packages that were loaded with micropip this time. Loading packages with loadPackage() is much faster and you will always get consistent versions of all your dependencies.

You can use your custom lock file by passing an appropriate url to the lockFileURL of loadPyodide().

Return type:


micropip.add_mock_package(name, version, *, modules=None, persistent=False)#

Add a mock version of a package to the package dictionary.

This means that if it is a dependency, it is skipped on install.

By default a single empty module is installed with the same name as the package. You can alternatively give one or more modules to make a set of named modules.

The modules parameter is usually a dictionary mapping module name to module text.

    def module_method(an_argument):
        print("This becomes a module level argument")

    module_value = "this value becomes a module level variable"
    print("This is run on import of module")

If you are adding the module in non-persistent mode, you can also pass functions which are used to initialize the module on loading (as in importlib.abc.loader.exec_module ). This allows you to do things like use unittest.mock.MagicMock classes for modules.

def init_fn(module):
    print("Initing the module now!")


    "mylovely_module": init_fn
  • name (str) – Package name to add

  • version (str) – Version of the package. This should be a semantic version string, e.g. 1.2.3

  • modules (Optional[dict[str, Optional[str]]]) – Dictionary of module_name:string pairs. The string contains the source of the mock module or is blank for an empty module.

  • persistent (bool) – If this is True, modules will be written to the file system, so they persist between runs of python (assuming the file system persists). If it is False, modules will be stored inside micropip in memory only.

Return type:


Return type:


Return type:



Uninstall the given packages.

This function only supports uninstalling packages that are installed using a wheel file, i.e. packages that have distribution metadata.

It is possible to reinstall a package after uninstalling it, but note that modules / functions that are already imported will not be automatically removed from the namespace. So make sure to reload the module after reinstalling by e.g. running importlib.reload(module).


packages (str | list[str]) – Packages to uninstall.

Return type: