Python pip available packages

How to List Installed Python Packages

The Pip, Pipenv, Anaconda Navigator, and Conda Package Managers can all be used to list installed Python packages.

You can also use the ActiveState Platform’s command line interface (CLI), the State Tool to list all installed packages using a simple “state packages” command. For a complete list of all packages and dependencies (including OS-level and transitive dependencies, as well as shared libraries), you can use the Web GUI, which provides a full Bill of Materials view. Give it a try by signing up for a free ActiveState Platform account .

Before getting a list of installed packages, it’s always a good practice to ensure that up-to-date versions of Python, Pip, Anaconda Navigator and Conda are in place.

List Installed Packages with Pip

Both pip list and pip freeze will generate a list of installed packages, just with differently formatted results. Keep in mind that pip list will list ALL installed packages (regardless of how they were installed). while pip freeze will list only everything installed by Pip.

Package Version ---------------------------------- ---------- absl-py 0.7.0

List Packages in a Console with Pip

To list all installed packages from a Python console using pip, you can utilize the following script:

>>> import pkg_resources installed_packages = pkg_resources.working_set installed_packages_list = sorted(["%s==%s" % (i.key, i.version) for i in installed_packages]) print(installed_packages_list)
['absl-py==0.7.0', 'adodbapi==2.6.0.7', 'alabaster==0.7.12', 'alembic==1.0.7', 'amqp==2.4.1', 'anyjson==0.3.3',

List Modules in a Console without Pip

To list all installed modules from a python console without pip, you can use the following command:

Читайте также:  Cheat private css v34

Note that there are some drawbacks to this approach, including:

  • If there are a lot of installed packages, this method can take a long time to import each module before it can search that module’s path for sub-modules.
  • Modules that have code outside of an if __name__ == “__main__”: code block, and if user input is expected, may cause the code to enter an infinite loop or hang.

List Installed Packages with Pipenv

The pipenv lock -r command can be used to generate output from a pipfile.lock file in a pipenv environment. All packages, including dependencies will be listed in the output. For example:

-i https://pypi.org/simple certifi==2019.11.28 chardet==3.0.4 idna==2.9 requests==2.23.0 urllib3==1.25.8

List Installed Packages with Anaconda Navigator

To list installed packages in an Anaconda environment using Anaconda Navigator, do the following:

  • Start the Anaconda Navigator application.
  • Select Environments in the left column.
  • A dropdown box at the center-top of the GUI should list installed packages. If not, then select Installed in the dropdown menu to list all packages.

List Installed Packages with Conda

The conda list command can be used to list all packages in a conda environment:

# packages in environment at C:\Anaconda2_4.3.1: # _license 1.1 py27_1 alabaster 0.7.9 py27_0

Globally vs Locally Installed Packages

For information about generating a list of installed packages globally vs locally, refer to:

List Installed Packages with the ActiveState Platform

To view a list of installed Python packages in your currently active project using the ActiveState Platform, run the following command on the command line:

The output is a full list of installed packages in your current project:

matplotlib numpy pandas scikit-learn scipy

You can also obtain a complete software bill of materials view of all packages, dependencies, transitives dependencies (ie., dependencies of dependencies), OS-level dependencies and shared libraries (ie., OpenSSL) using the ActiveState Platform’s Web GUI:

BOM using Platform Web GUI

The ActiveState Platform automatically builds all Python packages including linked C libraries from source code, and packages them for Windows, Linux and macOS. Because it does it all server-side, there’s no need to maintain local build environments.

Источник

pip list#

List installed packages, including editables. Packages are listed in a case-insensitive sorted order.

Options#

-o , —outdated # List outdated packages -u , —uptodate # List uptodate packages -e , —editable # List editable projects. -l , —local # If in a virtualenv that has global access, do not list globally-installed packages. —user # Only output packages installed in user-site. —path # Restrict to the specified installation path for listing packages (can be used multiple times). —pre # Include pre-release and development versions. By default, pip only finds stable versions. —format # Select the output format among: columns (default), freeze, or json. The ‘freeze’ format cannot be used with the —outdated option. —not-required # List packages that are not dependencies of installed packages. —exclude-editable # Exclude editable package from output. —include-editable # Include editable package from output. —exclude # Exclude specified package from the output -i , —index-url # 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-index-url # Extra URLs of package indexes to use in addition to —index-url. Should follow the same rules as —index-url. —no-index # Ignore package index (only looking at —find-links URLs instead). -f , —find-links # 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.

Examples#

$ 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 
$ 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 
$ 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 
$ python -m pip list --format=json [, , . 
C:\> py -m pip list --format=json [, , . 
$ 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 

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 field.

$ 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 command, pip list —format=freeze will not report editable install information, but the version of the package at the time it was installed.

Источник

pip list#

List installed packages, including editables. Packages are listed in a case-insensitive sorted order.

Options#

-o , —outdated # List outdated packages -u , —uptodate # List uptodate packages -e , —editable # List editable projects. -l , —local # If in a virtualenv that has global access, do not list globally-installed packages. —user # Only output packages installed in user-site. —path # Restrict to the specified installation path for listing packages (can be used multiple times). —pre # Include pre-release and development versions. By default, pip only finds stable versions. —format # Select the output format among: columns (default), freeze, or json. The ‘freeze’ format cannot be used with the —outdated option. —not-required # List packages that are not dependencies of installed packages. —exclude-editable # Exclude editable package from output. —include-editable # Include editable package from output. —exclude # Exclude specified package from the output -i , —index-url # 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-index-url # Extra URLs of package indexes to use in addition to —index-url. Should follow the same rules as —index-url. —no-index # Ignore package index (only looking at —find-links URLs instead). -f , —find-links # 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.

Examples#

$ 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 
$ 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 
$ 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 
$ python -m pip list --format=json [, , . 
C:\> py -m pip list --format=json [, , . 
$ 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 

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 field.

$ 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 command, pip list —format=freeze will not report editable install information, but the version of the package at the time it was installed.

Источник

Оцените статью