I usually do this:
import matplotlib.pyplot as plt import sys print (sys.modules[plt.__package__].__version__)
if you import only the function:
from sklearn.metrics import confusion_matrix as function import sys try:module_name = function.__module__[:function.__module__.index(".")] except:module_name = function.__module__ print (sys.modules[module_name].__version__)
and if that doesn't work, you can just import pip and for code all the modules.
source share