After installing and configuring Google Cloud SDK gsutil
command can be run by simply typing its name and the argument(-s) using Windows cmd.
Here is the example:
"C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\bin\gcloud" version
But the same command fails if run using Python subprocess.
With subprocess's shell
argument set to True the ImportError
occurs:
import subprocess
cmd = '"C:/Program Files (x86)/Google/Cloud SDK/google-cloud-sdk/bin/gsutil" version'
p = subprocess.Popen(cmd, shell=True)
.....
ImportError: No module named site
With subprocess's shell
argument set to False then the WindowsError: [Error 2] The system cannot find the file specified
occurs:
p = subprocess.Popen(cmd, shell=False)
Is there a way to run gsutil
on Windows using Python?