1

I am running a Python script and if I find that a critical module is missing, I want to install it using pip. I am calling it via subprocess.call(["pip", "install", module_name]) from my script but the problem with this solution seems to be that it may trigger some other interpreter and potentially virtual environment - I have several of them at the same time on my machine. But I want to run the subprocess for exactly the same interpreter (may not be on the PATH) and environment which is currently executing my script. Any ideas how to solve this? (note that as a byproduct I also need to grab the stdout from the process)

  • I think this is dupliate of: http://stackoverflow.com/questions/12332975/installing-python-module-within-code. Btw. look at the answers to this question as it show how to solve your problem. – running.t Jan 10 '17 at 14:36
  • Possible duplicate of [Installing python module within code](http://stackoverflow.com/questions/12332975/installing-python-module-within-code) – running.t Jan 10 '17 at 14:39

0 Answers0