Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

git.exc.GitCommandNotFound: Cmd('git') not found due to: OSError('[Errno 20] Not a directory') for 2.1.15 #1151

Answered by Byron
caserffer asked this question in Q&A
Discussion options

my code is
image
image
and my error is:

Traceback (most recent call last):
 File "PrecisionDiff.py", line 250, in <module>
 obj.pares_from_git_log()
 File "PrecisionDiff.py", line 74, in pares_from_git_log
 self.REPO_EXECUTE.execute("git checkout master")
 File "/usr/local/lib/python2.7/dist-packages/git/cmd.py", line 738, in execute
 raise GitCommandNotFound(command, err)
git.exc.GitCommandNotFound: Cmd('git') not found due to: OSError('[Errno 20] Not a directory')
 cmdline: git checkout master

my git cmd run ok:
image

is something wrong? i can run the same code on windows but failed on ubuntu!

help me tks

You must be logged in to vote

GitPython tries very hard to find a suitable git executable on the system it is executed on, and I could imagine that this for some reason fails.
Before starting your program, or before importing GitPython, you can set the GIT_PYTHON_GIT_EXECUTABLE to the executable to use, like in GIT_PYTHON_GIT_EXECUTABLE=/usr/bin/git python myscript.py. That will force GitPython to use the specified executable, which usually works.

Hope that helps.

Replies: 2 comments

Comment options

GitPython tries very hard to find a suitable git executable on the system it is executed on, and I could imagine that this for some reason fails.
Before starting your program, or before importing GitPython, you can set the GIT_PYTHON_GIT_EXECUTABLE to the executable to use, like in GIT_PYTHON_GIT_EXECUTABLE=/usr/bin/git python myscript.py. That will force GitPython to use the specified executable, which usually works.

Hope that helps.

You must be logged in to vote
0 replies
Answer selected by Byron
Comment options

Along with GIT_PYTHON_GIT_EXECUTABLE, I needed to export also GIT_SSH_COMMAND. These worked for me. :-

export PATH=$PATH:/usr/bin/git
export GIT_PYTHON_GIT_EXECUTABLE=/usr/bin/git
export GIT_SSH_COMMAND="/usr/bin/ssh -i ~/.ssh/id_rsa"
You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
Converted from issue

This discussion was converted from issue #997 on February 26, 2021 11:18.

AltStyle によって変換されたページ (->オリジナル) /