无法从Python脚本运行Git命令
使用无法从Python脚本运行Git命令,python,python-3.x,git,Python,Python 3.x,Git,使用subprocess.call(“git sparse checkout”)执行git命令时,返回一个错误,表示git命令不存在: git: 'sparse-checkout' is not a git command. See 'git --help'. 但是,当在终端中运行相同的命令时,我能够使用稀疏签出而没有问题 subprocess.call(["which", "git"]) subprocess.call(["git"
subprocess.call(“git sparse checkout”)
执行git命令时,返回一个错误,表示git命令不存在:
git: 'sparse-checkout' is not a git command. See 'git --help'.
但是,当在终端中运行相同的命令时,我能够使用稀疏签出而没有问题
subprocess.call(["which", "git"])
subprocess.call(["git", "--version"])
我还尝试使用以下方法:
subprocess.call(['git', 'sparse-checkout'])
subprocess.call("git sparse-checkout", shell=True)
os.system("git sparse-checkout")
都返回相同的结果
我正在RHEL 6.6上使用git 2.26.2和Python 3.2您得到的关于
'sparce-checkout'的错误不是git命令
指向脚本初始化的git版本不>=git 2.26
看起来这是一个使用git的相对较新的命令。我会做两件事:
subprocess.call(["which", "git"])
subprocess.call(["git", "--version"])