[英]GitPython not able to import Repo from Git
I am having a python script like below in a file git.py 我在文件git.py中有如下所示的python脚本
#!/usr/bin/env python
# -*- coding:utf-8 -*-
from git import Repo
git_path = "test"
repo = Repo(git_path)
assert not repo.bare
Python version is : Python 2.7.12 Python版本是:Python 2.7.12
OS : Description: Ubuntu 16.04.1 LTS 操作系统:说明:Ubuntu 16.04.1 LTS
Gitpython - 2.1.7 Gitpython的-2.1.7
I am getting the below error when i run python git.py 当我运行python git.py时出现以下错误
Traceback (most recent call last):
File "git.py", line 4, in <module>
from git import Repo
File "/home/user/demo_files/git.py", line 4, in <module>
from git import Repo
ImportError: cannot import name Repo
I have checked most of the links ,available not able to resolve my issue. 我已经检查了大多数链接,无法解决我的问题。 Please help me.
请帮我。
将您的文件名从git.py更改为othername .py,因为您的文件引用自身,因此会引发错误
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.