Find out modules installed by pip

Writing by on Wednesday, 1 of October , 2014 at 3:52 am

We have a bunch of Python (2.7) virtual environments and I needed a way to figure out a way to list modules installed by pip within the context of that venv and then grep for a particular one. I’m not a super Python expert at this time, but wrote up a small script to list this.

Here’s a python script:

# pip_installed_modules.py 
import pip

def main():
	modules = pip.get_installed_distributions()
	for m in modules:
		print m


if __name__ == "__main__":
    main()

Here’s my alias:

alias pipmodules=’python ~/bin/pip_installed_modules.py’

Now I can simply grep for specific modules or just see the installed modules.

Leave a comment

Category: Python

No Comments

No comments yet.

Leave a comment

You must be logged in to post a comment.

Shivdev Kalambi's Blog

Shivdev Kalambi is a Software Development Manager, previously a Principal Software Engineer at ArcSight/HP. With over 16 years' experience in software development, he's worked on several technologies and played different roles and contributed to all phases of projects. Non-tech activies include Ping-pong, Rock Climbing and Yoga at PG, Golf, Skiing, Swimming & a beer enthusiast.