Python which packages are installed

How to find Python List Installed Modules and Version using pip?

Do you want to know all the Python version installed on your system?

I have also recorded a video with a live demo. You can watch or else continue reading.

The main strength of the Python is, the wide range of external libraries are available. As we keep coding in Python, we install many packages. It is easy getting a Python list installed modules on the system. There are a couple of ways you can do that.

Following are the two ways that will work for you to get this list…

1. Using help() function (without pip):

The simplest way is to open a Python console and type the following command…

This will gives you a list of the installed module on the system. This list contains modules and packages that come pre-installed with your Python and all other you have installed explicitly.

Here is an example of running help function on my system (Python version 2).

list of Python modules using help function example

You don’t need to install any external module to get this list with help() function. But this command does not give you any other information about the package.

If you want to know the version of each installed modules, you can use pip program.

2. Using pip to find Python list installed modules and their Versions:

To find the list of Python packages installed on the system, you can use pip program.

Those who don’t know about pip, it is the best program which is used to install and to manage other Python packages on your system. For more understanding, you can check the complete guide for managing Python modules using pip.

If you have the latest version of Python, pip comes preinstalled with Python.

Читайте также:  Таблицы

Run following commands on the command line (not on Python console). You get the complete list of installed Python modules with their versions.

Here is an example of listing Python package you have installed on your system using the pip tool.

list of Python modules using pip freeze example

Unlike help function, it does not list down preinstalled Python packages.

You can see all the Python packages followed by their version.

Note: Before running this command, ensure if there is a pip installed on your system. For Python version 2.7+ and 3.4+, it comes pre-installed with Python.

The format of the output list of both commands is totally different. Suppose you are using these command in shell scripting. You can choose any of the commands which you find easy for parsing the output package list and get the information.

If you already have parsing code for any of the output from two commands, you can use that command.

Related Read: Why you should learn Shell scripting? (Python vs Shell Scripting)

For more detail about any specific module, run command.

It returns the name of the module/package, version, author, author email, license, location of the installed module and requires.

You can get the author’s email. You can reach out to the author for any specific query related to the Python package.

If you are using python code for commercial purpose, knowing the package’s license is important.

How to Check if Python module is installed?

You can use pip commands with grep command to search for any specific module installed on your system.

For instance, you can also list out all installed modules with the suffix “re” in the module name.

How to count the number of Python modules installed on your system?

You can use wc (word count) command.

Note: grep and wc commands only work with Linux based systems.

What is the use of these commands?

  • You can use these commands to list out all the installed modules on your system. Later you can use this list to set up a new identical environment.
  • If you face any issue in installed Python package, running these commands make debugging easier.
  • Knowing Python module version, you can update the module if a new version of the module is available.

In an upcoming article, I will share, how you can write a Python program to get a list of Python packages and save them in a list.

If you find these commands useful for Python list installed modules, share with your friends. Feel free to write a comment if you have any question regarding handling Python 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.

Читайте также:  Php include что такое

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:

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:

Читайте также:  Генератор нечетных чисел python

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.

Источник

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

Источник

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