How to install requirements.txt file from a python module?

Viewed 3793

I am looking for an alternative to

pip install -r requirements.txt

which can be used to install packages from a python module. I have used

subprocess.check_call([sys.executable, "-m", "pip", "install", package])

for installing a package, however, this command seems to work only for a single package. Thanks in advance. Any help is appreciated.

1 Answers

Don't forget to replace "package" with "-r requirements.txt":

subprocess.check_call([sys.executable, "-m", "pip", "install", "-r", "requirements.txt"])
Related