How to retrieve pip requirements (freeze) within Python?

后端 未结 4 765
北海茫月
北海茫月 2020-12-17 16:41

I posted this question on the git issue tracker: https://github.com/pypa/pip/issues/2969

Can we have some manner of calling pip freeze/list within python, i.e. not a

4条回答
  •  半阙折子戏
    2020-12-17 16:59

    It's not recommended to rely on a "private" function such as pip._internal.operatons. You can do the following instead:

    import pkg_resources
    env = dict(tuple(str(ws).split()) for ws in pkg_resources.working_set)
    

提交回复
热议问题