chuwy chuwy - 3 months ago 34
Python Question

Installing python module within code

I need to install a package from PyPi straight within my script.
Maybe there's exists module or distutils (distribute, pip) ability which allows me just execute something like

and requests will be installed into my virtualenv, and I should not type
pip install requests
in my shell?


You can also use something like:

import pip

def install(package):
    pip.main(['install', package])

# Example
if __name__ == '__main__':