3

I tried

g = git.Repo(r'C:\Users\Administrator\Desktop\testRepo')
print g.untracked_files

But got:

git.exc.GitCommandNotFound: [Error 2]

Is it a bug?

LouYu
  • 671
  • 1
  • 6
  • 14

1 Answers1

6

I don't have this error when I do exactly the same.

Do you have git executable in your ${PATH} variable? If you are using bash you can run export PATH=$PATH:/path/to/your/git/executable

From exc.py in gitpython:

class GitCommandNotFound(Exception): """Thrown if we cannot find thegitexecutable in the PATH or at the path given by the GIT_PYTHON_GIT_EXECUTABLE environment variable""" pass one can assume that setting that env variable may also help.

You can also set env variable directly from python in platform-independent way as greatly described here, instead of modifying your startup script (aka ~/.bash_profile or similar ):

Python: Platform independent way to modify PATH environment variable

Community
  • 1
  • 1
Zloj
  • 2,235
  • 2
  • 18
  • 28