In this very short Python tutorial, you will learn how to list all installed packages in Python. There are 4 methods that enable you to get the list of installed packages on Python. First, we will use the
help("modules") command in a Jupyter lab notebook. Second, we will use the command-line tool pydoc. Third, we will use pip freeze to list all the installed packages in Python. Fourth, and finally, we will use pip list to get all the locally installed packages (e.g. in Virtual Environments).
2 Steps of List all Installed Packages in Python
In the first example, you will learn how to list all of you installed Python packages in a Jupyter lab notebook.
Step 1: Start a Jupter lab Notebook
Now, in the first step, you will need to start a Jupyter lab notebook. It is very simple. Just open up a Windows Command prompt (or a Terminal Window, in Linux). In this window, you type
Step 2: Use help() to Get all Python Packages
In the second, and final, step you will use the help() method to list all the installed Python packages in the Jupyter lab Notebook:
As you can see in the image above, you just type
help("modules") to get a list of all the Python packages you have installed.
There are so many cool things you can do with Python. For example, you can also get user input from the keyboard in Python.
List all Installed Packages in Python using Pydoc
In the next how to get all installed Packages in Python example, we are going to use the command-line tool pydoc:
Specifically, open up a Windows command prompt, terminal window, or anaconda prompt, and type
Note, however, that you get a list of all packages using the above to methods. That is, you get a list of all the modules you have, not only the ones you have installed. In the next section, you will learn how to get the installed Python packages.
Get all Installed Python Packages using Pip
Now, in this section, you will learn how to get all the installed Python packages using pip. In fact, you will learn two methods using pip. First, you will use
pip freeze. Second, you will use
- For an introduction to Python, see the post about the syntax, indentation, commenting, if-statements, etc., in Python.
Method 1: List Python Packages with Pip Freeze
In the first example, using pip, we will use freeze to get all the packages:
Method 2: List all Pyton Packages with Pip list:
Now, in the second method you will use
pip list to list all the locally installed Python packages.
That was all. Let us know if you need to learn other cool things with Python!