How to list all installed packages and their versions in Python?

前端 未结 12 2022
灰色年华
灰色年华 2020-12-12 10:07

Is there a way in Python to list all installed packages and their versions?

I know I can go inside python/Lib/site-packages and see what files and direc

12条回答
  •  余生分开走
    2020-12-12 10:35

    To run this in later versions of pip (tested on pip==10.0.1) use the following:

    from pip._internal.operations.freeze import freeze
    for requirement in freeze(local_only=True):
        print(requirement)
    

提交回复
热议问题