Created
March 22, 2021 11:38
-
-
Save raggleton/f12d51f78e7b2e954edae3b22711be03 to your computer and use it in GitHub Desktop.
List versions of imported packages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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