Trying to call pip from a python script to install a package in a virtual env.
opt = '--dry-run,' if dry_run else ''
args = f'{project.venv_path}/bin/python3 -m pip install {opt} --report - django'
try:
completedProcess = subprocess.run(shlex.split(args),
encoding='utf-8',
capture_output=True,
check=True)
project.django_requirements = completedProcess.stdout
return completedProcess.returncode
except subprocess.CalledProcessError as e:
print('subprocess error for pip install django')
print(e.stdout)
print(e.stderr)
return e.returncode
I keep getting the following error message : no such option --dry-run
or no such option --report depending of the order of the option in args !..
What did I miss?