I'm using virtualenvwrapper in my deployment. To setup new environments, I'm running a python script, which contains all needed steps.
The setupscript includes:
cmd = 'mkvirtualenv %s --no-site-packages'%('testname')
head = subprocess.Popen(cmd,shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
for line in head.stdout.read().splitlines():
print line
The output is:
/bin/sh: mkvirtualenv: not found
How can I correctly use virtualenvwrapper within my python script?
EDIT:
The following code works for me:
cmd = 'source /usr/local/bin/virtualenvwrapper.sh && mkvirtualenv %s --no-site-packages'%('testname')
head = subprocess.Popen(cmd, executable='bash', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
for line in head.stdout.read().splitlines():
print line
Thanks for all answers.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…