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
The other answers here are unsupported by pip: https://pip.pypa.io/en/stable/user_guide/#using-pip-from-your-program
According to pip developers:
If you're directly importing pip's internals and using them, that isn't a supported usecase.
try
reqs = subprocess.check_output([sys.executable, '-m', 'pip', 'freeze'])