Python show all installed packages

How to List Python Packages – Globally Installed vs Locally Installed

When a package is installed globally, it’s made available to all users that log into the system. Typically, that means Python and all packages will get installed to a directory under /usr/local/bin/ for a Unix-based system, or \Program Files\ for Windows.

Conversely, when a package is installed locally, it’s only made available to the user that installed it. Locally installed Python and all packages will be installed under a directory similar to ~/.local/bin/ for a Unix-based system, or \Users\Username\AppData\Local\Programs\ for Windows.

How to List Python Packages

As a best practice, you should always install Python and the packages you need into a separate virtual environment for each project. This creates an isolated environment that will avoid many of the problems that arise because of shared libraries/ dependencies.

The Pip Package Manager can be used to list both globally and locally installed Python packages. The Pipenv, Anaconda Navigator and Conda package managers can also be used to list locally installed packages in their respective environments.

Читайте также:  Php call function on array elements

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

How to List Python Packages that are Globally Installed

Pip installs packages globally by default. To list globally installed packages and their version # use:

To list a single globally installed package and its version #, use the following command depending on your OS:

How to List Python Packages that are Locally Installed

Pip

Although pip installs packages globally by default, packages that have been installed locally with the –user option can also be listed using the same –user option, as follows:

If you just want to list a single, locally installed package and its version #, you can use one of the following commands, depending on your OS:

Pipenv

To list locally installed packages and their version # within a pipenv environment, cd into a pipenv project and enter the following command:

This command will list all packages installed, including any dependencies that are found in a Pipfile.lock file.

ActiveState Platform

If you prefer to see a visual representation of the packages in your local/virtual environment, you can use the ActiveState Platform’s Web GUI, which shows:

  • Installed top-level packages
  • Installed package dependencies
  • Installed shared (i.e., OS-level) dependencies

BOMcomplete

Conda

To list locally installed packages and their version # within a Conda environment, open the Anaconda Prompt and enter the following command:

Anaconda Navigator

To list all installed packages in a local Anaconda environment using Anaconda Navigator, do the following:

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

How to Determine the Location of Globally Installed Packages

As noted earlier, globally installed Python packages can typically be found in the default install location for your OS. However, it is possible to install packages into a non-default directory. In order to determine where global packages have been installed, use the following command:

To show the location of globally installed packages in a python console, use the following script:

>>> import site >>> print(site.getsitepackages())'

Using Pip Show for Package Location

The pip show command can provide information about a single, globally installed package, including its location:

How to Determine the Location of Locally Installed Packages

To list the location of locally installed packages, use the following command:

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.

Источник

List all packages, modules installed in python – pip list

There are three ways to get the list of all the libraries or packages or modules installed in python using pip list command, pip freeze command and help function .

All the three ways of listing all the packages installed in python are explained below along with we also explained.

  • Pip list all the outdated package installed in python
  • pip list all the up to date package installed in python
  • pip list all installed packages in json format
  • pip list installed packages along with package version

1. List all the packages, modules installed in python Using pip list:

open Anaconda prompt and type the following command.

This will get the list of installed packages along with their version in angular braces which is shown below

list of all packages and libraries installed in python 3

Syntax for pip list command :

Some Examples of pip list command with options:

pip list - list all packages and modules installed in python 1

pip list - list all packages and modules installed in python 2

c) List all outdated Packages that are not dependencies of other packages.

pip list - list all packages and modules installed in python 3

d) pip list – list all the packages installed using json formatting

pip list - list all packages and modules installed in python 4

pip list - list all packages and modules installed in python 5

f) pip list – python List packages that are not dependencies of installed packages.

pip list - list all packages and modules installed in python 6

g) pip list – python list all package that are upto date.

pip list - list all packages and modules installed in python 7

2. Get the list of all the packages in python Using Help function: To get the list of installed packages in python you can simply type the below command in python IDE

list of all packages and libraries installed in python 1This will list all the modules installed in the system . list of all packages and libraries installed in python 2

3. List all the packages, modules installed in python Using pip freeze:

list of all packages and libraries installed in python 4

This will get the list of installed packages along with their version as shown below These are the three different methods that lists the packages or libraries installed in python.

Author

With close to 10 years on Experience in data science and machine learning Have extensively worked on programming languages like R, Python (Pandas), SAS, Pyspark. View all posts

Источник

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.

Источник

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