Package for listing version of packages used in a Jupyter notebook

前端 未结 7 1152
遥遥无期
遥遥无期 2020-12-13 19:50

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

7条回答
  •  独厮守ぢ
    2020-12-13 20:38

    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())
    

提交回复
热议问题