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 shell context?
I want to be able to import pip and do something like requirements = pip.freeze(). Calling pip.main(['freeze']) writes to stdout, doesn't return str values.
Actually from
pip >= 10.0.0
packageoperations.freeze
has moved topip._internal.operations.freeze
.So the safe way to import
freeze
is:There's a pip.operation.freeze in newer releases (>1.x):
Output is as expected: