python - Programmatically generate requirements.txt file -
python - Programmatically generate requirements.txt file -
i'm trying generate requirements.txt file programatically. way can diff against sec .txt file. far i've tried following, output requirements console (no .txt file generated).
so far i've tried
import pip pip.main(["freeze",">","requirements.txt"])
and
subprocess import phone call call(["pip","freeze", ">","requirements.txt"])
if effort run same command manually in terminal though, file generated without issue. suggestions?
ask pip straight provide list of distributions script myfreeze.py
import pip open("requirements.txt", "w") f: dist in pip.get_installed_distributions(): req = dist.as_requirement() f.write(str(req) + "\n")
then expected content in requirements.txt
file.
python subprocess pip requirements.txt
Comments
Post a Comment