What is the best way of listing all imported modules in python?

落花浮王杯 提交于 2019-12-24 05:39:50

问题


Usually, after doing numerical SciPy/NumPy calculations in the interactive mode for several hours, a bunch of modules become to be loaded.

Are there any good ways to see the list of imported modules from the interactive python command line?

Thanks!


回答1:


Use sys.modules:

import sys
print '\n'.join(sys.modules)



回答2:


Use Pip

pip freeze

Using:

pip freeze > requirements.txt 

will save all the modelues in a text file.



来源:https://stackoverflow.com/questions/32236052/what-is-the-best-way-of-listing-all-imported-modules-in-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!