Created
February 4, 2020 02:02
-
-
Save jorgerance/68aecdb4ceae050ebea3fa34d656c5cf to your computer and use it in GitHub Desktop.
[print imports version] #python #imports #version
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
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