python -m pip list [options]
py -m pip list [options]
列出已安装的包,包括可编辑的。
Packages are listed in a case-insensitive sorted order.
List outdated packages
列出最新的包
列出可编辑工程。
If in a virtualenv that has global access, do not list globally-installed packages.
Only output packages installed in user-site.
Restrict to the specified installation path for listing packages (can be used multiple times).
Include pre-release and development versions. By default, pip only finds stable versions.
Select the output format among: columns (default), freeze, or json
List packages that are not dependencies of installed packages.
Exclude editable package from output.
Include editable package from output.
Exclude specified package from the output
Base URL of the Python Package Index (default https://pypi.org/simple ). This should point to a repository compliant with PEP 503 (the simple repository API) or a local directory laid out in the same format.
Extra URLs of package indexes to use in addition to --index-url. Should follow the same rules as --index-url.
Ignore package index (only looking at --find-links URLs instead).
If a URL or path to an html file, then parse for links to archives such as sdist (.tar.gz) or wheel (.whl) files. If a local path or file:// URL that’s a directory, then look for archives in the directory listing. Links to VCS project URLs are not supported.
List installed packages (with the default column formatting).
$ python -m pip list Package Version ------- ------- docopt 0.6.2 idlex 1.13 jedi 0.9.0
C:\> py -m pip list Package Version ------- ------- docopt 0.6.2 idlex 1.13 jedi 0.9.0
List outdated packages with column formatting.
$ python -m pip list --outdated --format columns Package Version Latest Type ---------- ------- ------ ----- retry 0.8.1 0.9.1 wheel setuptools 20.6.7 21.0.0 wheel
C:\> py -m pip list --outdated --format columns Package Version Latest Type ---------- ------- ------ ----- retry 0.8.1 0.9.1 wheel setuptools 20.6.7 21.0.0 wheel
List packages that are not dependencies of other packages. Can be combined with other options.
$ python -m pip list --outdated --not-required Package Version Latest Type -------- ------- ------ ----- docutils 0.14 0.17.1 wheel
C:\> py -m pip list --outdated --not-required Package Version Latest Type -------- ------- ------ ----- docutils 0.14 0.17.1 wheel
Use json formatting
$ python -m pip list --format=json [{'name': 'colorama', 'version': '0.3.7'}, {'name': 'docopt', 'version': '0.6.2'}, ...
C:\> py -m pip list --format=json [{'name': 'colorama', 'version': '0.3.7'}, {'name': 'docopt', 'version': '0.6.2'}, ...
Use freeze formatting
$ python -m pip list --format=freeze colorama==0.3.7 docopt==0.6.2 idlex==1.13 jedi==0.9.0
C:\> py -m pip list --format=freeze colorama==0.3.7 docopt==0.6.2 idlex==1.13 jedi==0.9.0
List packages installed in editable mode
When some packages are installed in editable mode,
pip list
outputs an additional column that shows the directory where the editable project is located (i.e. the directory that contains the
pyproject.toml
or
setup.py
file).
$ python -m pip list Package Version Editable project location ---------------- -------- ------------------------------------- pip 21.2.4 pip-test-package 0.1.1 /home/you/.venv/src/pip-test-package setuptools 57.4.0 wheel 0.36.2
C:\> py -m pip list Package Version Editable project location ---------------- -------- ---------------------------------------- pip 21.2.4 pip-test-package 0.1.1 C:\Users\You\.venv\src\pip-test-package setuptools 57.4.0 wheel 0.36.2
The json format outputs an additional
editable_project_location
字段。
$ python -m pip list --format=json | python -m json.tool [ { "name": "pip", "version": "21.2.4", }, { "name": "pip-test-package", "version": "0.1.1", "editable_project_location": "/home/you/.venv/src/pip-test-package" }, { "name": "setuptools", "version": "57.4.0" }, { "name": "wheel", "version": "0.36.2" } ]
C:\> py -m pip list --format=json | py -m json.tool [ { "name": "pip", "version": "21.2.4", }, { "name": "pip-test-package", "version": "0.1.1", "editable_project_location": "C:\Users\You\.venv\src\pip-test-package" }, { "name": "setuptools", "version": "57.4.0" }, { "name": "wheel", "version": "0.36.2" } ]
注意
Contrary to the
freeze
命令,
pip list --format=freeze
will not report editable install information, but the version of the package at the time it was installed.