我想获得Python模块的列表,这些模块在我的Python安装(UNIX服务器)中。
如何获得安装在计算机上的Python模块的列表?
发布于 2018-04-25 10:58:49
从pip 10开始,接受的答案将不再有效。开发团队已经删除了对get_installed_distributions例程的访问。在setuptools中有一个替代函数来做同样的事情。以下是适用于pip 10的替代版本:
import pkg_resources
installed_packages = pkg_resources.working_set
installed_packages_list = sorted(["%s==%s" % (i.key, i.version)
for i in installed_packages])
print(installed_packages_list)请让我知道它在以前的pip版本中是否也能工作。
https://stackoverflow.com/questions/739993
复制相似问题