0

I've install git python, details:

Python 3.8.1
git version 2.21.1 (Apple Git-122.3)
GitPython==3.1.0
gitdb==4.0.2
OS is Catalina
virtual environment via pyenv, pyenv-virtualenv, pyenv-virtualenvwrapper
git is located in /usr/bin/git

running this code:

from git import cmd
import sys

sys.path.append('/usr/bin/')
g = cmd.Git()
g.execute('git') # prints the git help page.
g.execute('git log') # Throws an error. 

g_ = cmd.Git('..')
g_.execute('git'). # prints the git help page.
g_.execute('git log'). # Throws an error. 

Error is:

GitCommandNotFound: Cmd('git') not found due to: FileNotFoundError('[Errno 2] No such file or directory: 'git log'')
cmdline: git log

This is actually an error from a third party library. I've replicated the error from that code with simpler code. original code calls git remote show origin which also has a similar error.

2
  • 2
    sys.path is NOT the same as os.environ['PATH']. sys.path is the parsed environment variable PYTHONPATH which refers to where to import Python packages from, not where to find executables. What's your current value of os.environ['PATH']? Commented Mar 13, 2020 at 15:54
  • '/Users/alesi/.virtualenvs/scrape_horses/bin:/Users/alesi/.pyenv/versions/3.8.1/bin:/usr/local/Cellar/pyenv/1.2.16/libexec:/Users/alesi/.pyenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin' at debug on exception. Commented Mar 13, 2020 at 15:55

1 Answer 1

1

execute receives a list of command line arguments, not a single string:

g.execute(['git', 'log']) #  Correct!
g.execute('git log') #  Wrong!
g.execute('git') #  Correct because only a single argument
Sign up to request clarification or add additional context in comments.

1 Comment

Solved this bug in the third party code, now onto the next bug in the third party code

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.