How can I get a list of locally installed Python modules?

前端 未结 30 2588
庸人自扰
庸人自扰 2020-11-22 04:32

I would like to get a list of Python modules, which are in my Python installation (UNIX server).

How can you get a list of Python modules installed in your computer?

30条回答
  •  温柔的废话
    2020-11-22 05:09

    Works Regardless of Pip Version

    Run the following in your python editor or IPython:

    import pkg_resources
    installed_packages = {d.project_name: d.version for d in pkg_resources.working_set}
    print(installed_packages)
    

    Read other answers and pulled together this combo, which is quickest and easiest inside Python.

    Find the specific Packages

    Conveniently you can then get items from your dict easily, i.e.

    installed_packages['pandas'] >> '1.16.4'

提交回复
热议问题