I need to list all imported modules together with their version. Some of my code only works with specific versions and I want to save the version of the packages, so that I can look it up again in the future. Listing the names of the packages works:
modules = list(set(sys.modules) & set(globals()))
print modules
But if I now want to get the version of the list items it doesn't work with:
for module in modules:
print module.__version__
Is there a way to address the .__version__
command with a string, or have I to go another way to get the name and the version?
In other questions only the names of the modules are addressed: How to list imported modules?