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())
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…