为什么Windows上的gitpython总是会找到找不到文件的错误?

时间:2014-10-17 16:27:22

标签: python git gitpython

查看位于here的教程以获取gitpython,然后逐步执行我的计算机上的一些问题。环境是Windows 7,git版本1.7.11.msysgit.1和Python 2.7。使用easy_install安装好的一切。已成功创建Repo对象,并且repo.tree()repo.branches等命令有效。如果我执行repo.is_dirty(),则会发现非特定文件未找到错误。 WindowsError: [Error 2] The system cannot find the file specified.有什么想法吗?

path = "c:\\path_to_repo"
repo = Repo(path)
assert repo.bare == False
print repo.tree()

repo.branches

print dir(repo)

#these always crash...
repo.is_dirty()

TIA提供任何帮助。

1 个答案:

答案 0 :(得分:1)

git.ext中可能没有PATH,但可以通过自己执行来轻松测试。如果您看到错误,可以将其添加到PATH,或将GIT_PYTHON_GIT_EXECUTABLE设置为git-python应为git命令行服务执行的可执行文件。

它适用于.tree()和相关对象查询的原因是gitpython使用pure-python后端进行这些操作。像.is_dirty()这样的更复杂的操作仍然需要git可执行文件默认位于PATH