Reputation: 11
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
Upvotes: 1
Views: 373
Reputation: 61
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:
subprocess.call(["which", "git"])
subprocess.call(["git", "--version"])
Upvotes: 1