Skip to content

Instantly share code, notes, and snippets.

@jorgerance
Created February 4, 2020 02:02
Show Gist options
  • Save jorgerance/68aecdb4ceae050ebea3fa34d656c5cf to your computer and use it in GitHub Desktop.
Save jorgerance/68aecdb4ceae050ebea3fa34d656c5cf to your computer and use it in GitHub Desktop.
[print imports version] #python #imports #version
def imports_version():
"""
Print imported modules and its version
Source: https://stackoverflow.com/a/50396275
"""
import sys
for module in sys.modules:
try:
print(module,sys.modules[module].__version__)
except:
try:
if type(modules[module].version) is str:
print(module,sys.modules[module].version)
else:
print(module,sys.modules[module].version())
except:
try:
print(module,sys.modules[module].VERSION)
except:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment