Im working on logic to automate process of pyenv virtualenv creation using subprocess. Trying to run multiple pyenv shell commands at one go as below
def subprocess_cmd(command):
process = subprocess.Popen(command,stdout=subprocess.PIPE, shell=True)
proc_stdout = process.communicate()[0].strip()
process.poll()
print (proc_stdout)
def run_cmd():
python_version = "3.9.6"
dirName = "D:/python_venv" + '/' + str(python_version)
os.makedirs(dirName, exist_ok=True)
try:
subprocess_cmd('pyenv install -l,pyenv install 3.9.0,pyenv local 3.9.6,python -m venv .venv')
except subprocess.CalledProcessError as exception:
return None
run_cmd()
Unfortunately, its not successful. Throwing below error
:: [Info] :: Mirror: https://www.python.org/ftp/python
pyenv-install: definition not found: -l;
See all available versions with `pyenv install --list'.
Process finished with exit code 0