gpt4 book ai didi

python - 用于列出 Jupyter 笔记本中使用的包版本的包

转载 作者:太空狗 更新时间:2023-10-29 18:20:53 27 4
gpt4 key购买 nike

我好像记得有一个包打印了 Jupyter notebook 中使用的 Python 包的版本和相关信息,所以里面的结果是可以重现的。但是我不记得包裹的名字了。你们中有人能指出我正确的方向吗?

提前致谢!

最佳答案

这会获取所有已安装的包

import pip #needed to use the pip functions
for i in pip.get_installed_distributions(local_only=True):
print(i)

获取当前笔记本的包列表

import types
def imports():
for name, val in globals().items():
if isinstance(val, types.ModuleType):
yield val.__name__
list(imports())

关于python - 用于列出 Jupyter 笔记本中使用的包版本的包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40428931/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com