When using subprocess.call("git sparse-checkout") to execute a git command it returns an error saying that the git command doesn't exist:
git: 'sparse-checkout' is not a git command. See 'git --help'.
When running the same command in the terminal, however, I am able to use sparse-checkout with no problems.
I have also tried to use the following:
subprocess.call(['git', 'sparse-checkout'])
subprocess.call("git sparse-checkout", shell=True)
os.system("git sparse-checkout")
All return the same result.
I am using git 2.26.2 and Python 3.2 on RHEL 6.6
1 Answer 1
The error you are getting about 'sparce-checkout' is not a git command points to the version of git the script is initializing is not >= git 2.26.
It looks like this is a relatively new command with git. Two things I would do:
- Verify the version of git the script is initializing and what you see in the terminal
subprocess.call(["which", "git"]) subprocess.call(["git", "--version"]) - If there are multiple versions of git use the full path to the binary