• Home
  • Subscribe
  • Contribute Us
    • Share Your Interview Experience
  • Contact Us
  • About
    • About CSEstack
    • Campus Ambassador
  • Forum & Discus
  • Tools for Geek
  • LeaderBoard
CSEstack

What do you want to Learn Today?

  • Programming
    • Tutorial- C/C++
    • Tutorial- Django
    • Tutorial- Git
    • Tutorial- HTML & CSS
    • Tutorial- Java
    • Tutorial- MySQL
    • Tutorial- Python
    • Competitive Coding Challenges
  • CSE Subject
    • (CD) Compiler Design
    • (CN) Computer Network
    • (COA) Computer Organization & Architecture
    • (DBMS) Database Management System
    • (DS) Data Structure
    • (OS) Operating System
    • (ToA) Theory of Automata
    • (WT) Web Technology
  • Interview Questions
    • Interview Questions- Company Wise
    • Interview Questions- Coding Round
    • Interview Questions- Python
    • Interview Questions- REST API
    • Interview Questions- Web Scraping
    • Interview Questions- HR Round
    • Aptitude Preparation Guide
  • GATE 2022
  • Linux
  • Trend
    • Full Stack Development
    • Artificial Intelligence (AI)
    • BigData
    • Cloud Computing
    • Machine Learning (ML)
  • Write for Us
    • Submit Article
    • Submit Source Code or Program
    • Share Your Interview Experience
  • Tools
    • IDE
    • CV Builder
    • Other Tools …
  • Jobs

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

Aniruddha Chaudhari/398319/10
CodePython

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…

help("modules")

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

HUGE list :O

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.

pip freeze

or

pip list

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.

pip show getopt

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.

pip list | grep getopt

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

pip list | grep re

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

You can use wc (word count) command.

pip list | wc -l

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.

What’s Next?

Check these 39 Most Useful Python Modules holding 95% Python Jobs.

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.

Happy Pythoning!

Python Interview Questions eBook

pipPython
Aniruddha Chaudhari
I am complete Python Nut, love Linux and vim as an editor. I hold a Master of Computer Science from NIT Trichy. I dabble in C/C++, Java too. I keep sharing my coding knowledge and my own experience on CSEstack.org portal.

Your name can also be listed here. Got a tip? Submit it here to become an CSEstack author.

Comments

  • Reply
    Sree
    May 3, 2017 at 12:58 am

    Good article. Though I am using python for the past many years just for fun on the coding challenges , I did not use much of modules except”math” in few cases. It would be nice if you write an article introducing each module and it’s primary usage.

    • Reply
      Aniruddha Chaudhari
      May 3, 2017 at 2:37 am

      Hey Sree, Thanks!

      It’s really good idea. I have used many Python modules, some for as per project need and some just to explore. It is not possible to cover all the modules. But I can curate most important and useful modules.

  • Reply
    Kanika Kher
    June 1, 2017 at 6:31 pm

    Good article!

    How to find the number of installed modules?

    I am using ubuntu system.

    • Reply
      Aniruddha Chaudhari
      June 1, 2017 at 6:35 pm

      Thanks for putting the point. I have updated the article.

      You can use the command “pip list | wc -l” in terminal. It will work in any of the Linux based systems including Ubuntu.

  • Reply
    Abhishek Saha
    March 29, 2019 at 8:57 pm

    Thanks Aniruddha , I’m new to python . I was looking for similar kind of help to explore python modules. Suppose I don’t know the module name to import or after importing , how to explore available command and its syntax .. this article given idea. If, possible, please explain bit about modules and how to use it ( VMware, AWS, MS Azure, Windows, Linux related modules).

    • Reply
      Aniruddha Chaudhari
      March 30, 2019 at 9:44 am

      Hi Abhishek,

      Pip is the standard tool used for all Python management activities. To search a specific module or to know all the commands related to the specific modules, you can use pip command line tool. There are various command provides detail about Python modules. You can find table listing of all such command in this tutorial.

      VMware, AWS, MS Azure, Windows, Linux are the platform where you can install any Python module. So it will not make much difference. Pip provides a common interface for all these platforms. Choose installing Python modules based on the Project requirement.

  • Reply
    Edward Bryant
    March 30, 2020 at 1:19 pm

    Thanks for these tricks and commands you shared in this tutorial. This helps me to understand more about Python modules.

    • Reply
      Aniruddha Chaudhari
      March 30, 2020 at 9:17 pm

      You’re welcome, Edward! I’m glad as you find this tutorial helpful for your learning.

  • Reply
    Theo
    January 9, 2021 at 7:42 pm

    Excellent. Look forward to rummaging around your site. Many thanks.

    • Reply
      Aniruddha Chaudhari
      January 11, 2021 at 10:53 am

      I’m glad you like our content. Your feedback is encouraging. Thanks, Theo!

Leave a Reply Cancel reply

Basic Python Tutorial

  1. Python- Tutorial Overview
  2. Python- Applications
  3. Python- Setup on Linux
  4. Python- Setup on Windows
  5. Python- Basic Syntax
  6. Python- Variable Declaration
  7. Python- Numeric Data Types
  8. Python- NoneType
  9. Python- if-else/elif
  10. Python- for/while else
  11. Python- User Input
  12. Python- Multiline User Input
  13. Python- String Formatting
  14. Python- Find Substring in String
  15. Python- Bitwise Operators
  16. Python- Range Function
  17. Python- List
  18. Python- List Vs Tuple
  19. Python- Compare Two Lists
  20. Python- Sorting List
  21. Python- Delete Element from List
  22. Python- Dictionary
  23. Python- ‘is’ vs ‘==’
  24. Python- Mutable vs Immutable
  25. Python- Generator & Yield
  26. Python- Fibonacci Generator
  27. Python- Assert Statement
  28. Python- Exception Handling 
  29. Python- RegEx
  30. Python- Lambda Function
  31. Python- Installing Modules
  32. Python- Important Modules
  33. Python- Find all Installed Modules
  34. PyCharm- IDE setup
  35. Python- File Handling
  36. Python- Monkey Patching
  37. Python- Decorators
  38. Python- Instance vs Static vs Class Method
  39. Python- Name Mangling
  40. Python- Working with GUI
  41. Python- Read Data from Web URL
  42. Python- Memory Management
  43. Python- Virtual Environment
  44. Python- Calling C Function

Python Exercise

  1. Python- Tricky Questions
  2. Python- Interview Questions (60+)
  3. Python- Project Ideas (45+)
  4. Python- MCQ Test Online
  5. Python- Coding Questions (50+)
  6. Python- Competitive Coding Questions (20+)

Python String

  1. Reverse the String
  2. Permutations of String
  3. Padding Zeros to String/Number

Python List

  1. Randomly Select Item from List
  2. Find Unique Elements from List
  3. Are all Elements in List Same?

Python Dictionary

  1. Set Default Value in Dictionary
  2. Remove all 0 from a dictionary

File Handling

  1. Python- Read CSV File into List
  2. Check if the File Exist in Python
  3. Find Longest Line from File

Compilation & Byte Code

  1. Multiple Py Versions on System
  2. Convert .py file .pyc file
  3. Disassemble Python Bytecode

Algorithms

  1. Sorting- Selection Sort
  2. Sorting- Quick Sort

Other Python Articles

  1. Clear Py Interpreter Console
  2. Can I build Mobile App in Python?
  3. Extract all the Emails from File
  4. Python Shell Scripting

© 2022 – CSEstack.org. All Rights Reserved.

  • Home
  • Subscribe
  • Contribute Us
    • Share Your Interview Experience
  • Contact Us
  • About
    • About CSEstack
    • Campus Ambassador
  • Forum & Discus
  • Tools for Geek
  • LeaderBoard