在windows下使用GitPython的时候,会产生这样的错误:
gitpython git.exc.GitCommandNotFound: Cmd('git') not found due to: FileNotFoundError
这是因为git的路径没有存储在环境变量中,打开cmd.exe输入git可以看到“git 不是内部或外部命令,也不是可运行的程序”(在git bash中可以正常使用)。
解决方案:将git的路径添加到环境变量path中即可,如添加:
D:\Git\bin\;D:\Git\libexec\git-core
等待一段时间后,命令即可生效,GitPython即可成功使用。