Quantcast
Channel: How do I get a list of locally installed Python modules? - Stack Overflow
Viewing all articles
Browse latest Browse all 35

Answer by yegle for How do I get a list of locally installed Python modules?

$
0
0
  1. to get all available modules, run sys.modules
  2. to get all installed modules (read: installed by pip), you may look at pip.get_installed_distributions()

For the second purpose, example code:

import pipfor package in pip.get_installed_distributions():    name = package.project_name # SQLAlchemy, Django, Flask-OAuthlib    key = package.key # sqlalchemy, django, flask-oauthlib    module_name = package._get_metadata("top_level.txt") # sqlalchemy, django, flask_oauthlib    location = package.location # virtualenv lib directory etc.    version = package.version # version number

Viewing all articles
Browse latest Browse all 35

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>