2012-07-07 63 views
2

最近我安裝的python-git的包,並試圖按照教程上通過以下鏈接的時候,我發現某些方法缺少...不能按照蟒蛇git的教程

http://packages.python.org/GitPython/0.3.2/tutorial.html#tutorial-label

這裏是走出我解釋的:

>>> from git import * 
>>> repo = Repo.init('/home/deostroll/scripts/synchost') 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
AttributeError: type object 'Repo' has no attribute 'init' 
>>> repo = Repo('/home/deostroll/scripts/synchost') 
>>> repo.is_dirty() 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
TypeError: 'bool' object is not callable 
>>> 
+0

我在看教程的過時版本嗎? – deostroll 2012-07-07 18:12:39

回答

2

這些命令適用於我,所以我同意你可能使用過時版本的其他答案。如果你在Linux和有PIP,安裝,在命令行中,你可以這樣做:

pip install --upgrade GitPython 

升級到最新版本。 (旁註:對於我在Fedora上,命令實際上是pip-python,所以它取決於你的發行版)。

2

這很可能是你使用的GitPython一個非常過時verison。在版本0.3中,is_dirty是一種方法,存在init

在0.1版中,is_dirtyproperty,並且init_bare被定義,但不是init

+0

我從Ubuntu的軟件中心得到了這個...而且版本已經過時了! – deostroll 2012-07-07 18:25:22