1

I am having a python script like below in a file git.py

#!/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

OS : Description: Ubuntu 16.04.1 LTS

Gitpython - 2.1.7

I am getting the below error when i run 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.

3
  • 1
    You need to rename your script to something other than git.py. Commented Nov 8, 2017 at 10:52
  • I changed it to test2.py, stil lthe same issue. Commented Nov 8, 2017 at 11:14
  • you are correct i had my pyc file remaning in the fodler thats why it was not working . thank you Commented Nov 8, 2017 at 11:21

1 Answer 1

6

Change your file name from git.py to othername .py, since your file is referring to itself it is throwing error

Sign up to request clarification or add additional context in comments.

Comments

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.