0

I am using GitPython to fetch a remote repository to my machine. The following code works well on my Ubuntu 12.04 but on my amazon ec2, on a Ubuntu 11.10 server, I get the OSError: [Errno 2] No such file or directory error.

 repo = git.Repo.init(fs_path)
 origin = repo.create_remote('origin',repo_url)
 origin.fetch()
 origin.pull(origin.refs[0].remote_head)

When I run the block in a script, I don't get any error messages. But when I try these steps on Interactive shell I get this stack trace:

>>> import git
>>> repo = git.Repo.init("/var/wwww/dir/subdir/tmp/12")
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 File "/usr/local/lib/python2.7/dist-packages/GitPython-0.3.2.RC1-py2.7.egg/git/repo/base.py", line 656, in init
 output = git.init(**kwargs)
 File "/usr/local/lib/python2.7/dist-packages/GitPython-0.3.2.RC1-py2.7.egg/git/cmd.py", line 227, in <lambda>
 return lambda *args, **kwargs: self._call_process(name, *args, **kwargs)
 File "/usr/local/lib/python2.7/dist-packages/GitPython-0.3.2.RC1-py2.7.egg/git/cmd.py", line 456, in _call_process
 return self.execute(call, **_kwargs)
 File "/usr/local/lib/python2.7/dist-packages/GitPython-0.3.2.RC1-py2.7.egg/git/cmd.py", line 335, in execute
 **subprocess_kwargs
 File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
 errread, errwrite)
 File "/usr/lib/python2.7/subprocess.py", line 1239, in _execute_child
 raise child_exception
OSError: [Errno 2] No such file or directory
>>> 

But I have no such issues on my local machine. No idea what's going wrong. Any help will be highly appreciated!

asked May 29, 2012 at 18:35
1
  • the path exists and python can access it Commented May 29, 2012 at 18:42

1 Answer 1

3

The error is coming out of the subprocess module. This suggests that git is either not installed on your EC2 instance or is in a location that is not in your PATH environment variable.

Note that GitPython depends on the git command-line tools. If you want a native Python module for interacting with Git repositories, take a look at dulwich.

answered May 29, 2012 at 19:08
Sign up to request clarification or add additional context in comments.

1 Comment

I just found that out myself and came here to answer the question. Yes, indeed I didn't have git installed and that was causing the error. Thanks for your prompt reply. I just wish Gitpython emitted a more meaningful error message/exception. If a library depends on an external tool, the first thing the library should do is to check if the dependency is installed. Had a tough hour with this. Thanks again!

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.