I seem to remember there is a package that printed the versions and relevant information about Python packages used in a Jupyter notebook so the results in it were reproduci
This gets all the installed packages
import pip #needed to use the pip functions
for i in pip.get_installed_distributions(local_only=True):
print(i)
To get the list of packages from current notebook
import types
def imports():
for name, val in globals().items():
if isinstance(val, types.ModuleType):
yield val.__name__
list(imports())