1

Is it possible to achieve the same behaviour of:

pip install -r requirements.txt

But programmatically with python?

For example (pseudocode):

from pip.reqs import install_requirements

install_requirements(file='requirements.txt')

And if not why? What is the best practice?

nemesisdesign
  • 8,159
  • 12
  • 58
  • 97
  • 1
    Here's a similar question: [http://stackoverflow.com/questions/12966147/how-can-i-install-python-modules-programmatically-through-a-python-script][1] Hope it helps you. [1]: http://stackoverflow.com/questions/12966147/how-can-i-install-python-modules-programmatically-through-a-python-script – giosans May 27 '14 at 12:56

1 Answers1

2

You need pip to be install prior to

import pip

# to install requirements
pip.main(['install', '-r', 'requirements.txt'])

# to install one package
pip.main(['install', 'package_name'])
naren
  • 14,611
  • 5
  • 38
  • 45