How Would I Run Lsvirtualenv Or Any Of The Other Virtualenvwrapper Functions Via Python Script?
I'm attempting to run virtualenvwrapper.sh commands (ie: lsvirtualenv and mkvirtualenv). I attempted to use subprocess.call(['lsvirtualenv']) but it does not seem to work. It giv
Solution 1:
You need to use source $(which virtualenvwrapper.sh) && <your command>
with shell=True
.
Example:
>>>from __future__ import print_function>>>from subprocess import Popen, PIPE>>>p = Popen("source $(which virtualenvwrapper.sh) && lsvirtualenv", shell=True, stdout=PIPE)>>>print(p.stdout.read())
10leds
======
ambientlight
============
See the documentation for the Popen Constructor.
Post a Comment for "How Would I Run Lsvirtualenv Or Any Of The Other Virtualenvwrapper Functions Via Python Script?"