3

I am trying to use difflib but it's giving an import error. Can someone please help? Here is the traceback :

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "difflib.py", line 1, in <module>
    from difflib import SequenceMatcher
ImportError: cannot import name SequenceMatcher
silent_dev
  • 1,566
  • 3
  • 20
  • 45

1 Answers1

4

The solution is to not name the source file difflib.py since in such case Python takes that instead of the actually desired difflib.

(Since the question was solved in the comments and no answer has been posted, inspired by a relevant meta question I'm adding this answer to make the question complete. I'm not trying to get credit for Kevin's or BrenBarn's solution and I'm posting it as a community wiki answer.)

Community
  • 1
  • 1
geckon
  • 8,316
  • 4
  • 35
  • 59