Skip to content

Instantly share code, notes, and snippets.

@raggleton
Created March 22, 2021 11:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raggleton/f12d51f78e7b2e954edae3b22711be03 to your computer and use it in GitHub Desktop.
Save raggleton/f12d51f78e7b2e954edae3b22711be03 to your computer and use it in GitHub Desktop.
List versions of imported packages
import sys
import types
def list_import_versions():
imports = []
for val in globals().values():
if isinstance(val, types.ModuleType) and val.__name__ != 'builtins':
full_name = val.__name__
version = getattr(sys.modules[full_name], '__version__', None) # skips builtins
if version:
print(full_name, version)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment