- micropip.freeze() str #
Produce a json string which can be used as the contents of the
If you later load Pyodide with this lock file, you can use
pyodide.loadPackageto load packages that were loaded with micropip this time. Loading packages with
pyodide.loadPackageis 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 argument to
- async micropip.install(requirements: str | list[str], keep_going: bool = False, deps: bool = True, credentials: Optional[str] = None, pre: bool = False) None #
Install the given package and all of its dependencies.
See loading packages for more information.
If a package is not found in the Pyodide repository it will be loaded from PyPI. Micropip can only load pure Python packages or for packages with C extensions that are built for 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
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
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.
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:
False, an error will be raised on first package with a missing wheel.
True, the micropip will keep going after the first error, and report a list of errors at the end.
bool, default: True
True, install dependencies specified in METADATA file for each package. Otherwise do not install dependencies.
This parameter specifies the value of
credentialswhen calling the fetch() function which is used to download the package.
When not specified,
fetch()is called without
bool, default: False
True, include pre-release and development versions. By default, micropip only finds stable versions.
Futurethat resolves to
Nonewhen all packages have been downloaded and installed.
- Return type
Get the dictionary of installed packages.
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.