Skip to content

AttributeError: module 'diff_match_patch' has no attribute 'diff' #39

Open

Description

@horror-vacui
 $ pdf-diff journal.pdf journal_v3.pdf > comparison.png
Traceback (most recent call last):
  File "/usr/local/bin/pdf-diff", line 10, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/dist-packages/pdf_diff/command_line.py", line 497, in main
    changes = compute_changes(args.files[0], args.files[1], top_margin=float(args.top_margin), bottom_margin=float(args.bottom_margin))
  File "/usr/local/lib/python3.6/dist-packages/pdf_diff/command_line.py", line 17, in compute_changes
    diff = perform_diff(docs[0][1], docs[1][1])
  File "/usr/local/lib/python3.6/dist-packages/pdf_diff/command_line.py", line 122, in perform_diff
    return diff_match_patch.diff(
AttributeError: module 'diff_match_patch' has no attribute 'diff'

 $ pip3 install diff_match_patch
Requirement already satisfied: diff_match_patch in /usr/local/lib/python3.6/dist-packages (20181111)

I've got the the problem above on a Xubuntu 18.04.3 LTS machine witch python 3.6. pdf-diff version 0.9.1 was installed through pip. I am not sure how to debug it further, or what further information are needed to diagnose the error.

Python 3.6.8 (default, Oct  7 2019, 12:59:55) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import diff_match_patch
>>> dir(diff_match_patch)
['__author__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__packager__', '__path__', '__spec__', '__version__', 'diff_match_patch', 'patch_obj', 'sys']

Activity

  1. JoshData commented on Jan 17, 2020

    @JoshData
    Owner
  2. Grandement commented on Jan 28, 2020

    @Grandement

    Hi,

    I have the same problem. Is it possible that you have a typo in the script?

    image

    Maybe it is diff_match_patch.diff_main instead of just diff_match_patch.diff?

  3. SaiSandeepKantareddy commented on Dec 3, 2020

    @SaiSandeepKantareddy

    hi, for windows there isn't anything like pdf-diff we have to install poppler and visual c++ 14.0 requirement, and then it works,
    it is pip install diff_match_patch_python

  4. readjfb commented on Sep 3, 2021

    @readjfb

    This issue is caused by a name collision issue between diff_match_patch and diff_match_patch_python. This program requires diff_match_patch-python, but diff_match_patch is installed by default on many systems. I uninstalled diff_match_patch using pip uninstall diff_match_patch and it works as intended.

    I'm on MacOS using a Conda environment with Python 3.9 installed.

    I'm not sure if this is an optimal solution, as diff_match_patch seems to be a frequently used library, but it works for me.

  5. ErqingLi commented on Oct 21, 2021

    @ErqingLi

    It works for me if I change line 122 into diff_match_patch.diff_match_patch().diff_main

  6. Vetrivel-PS commented on Mar 29, 2022

    @Vetrivel-PS

    Use

    pip uninstall diff_match_patch

    and

    pip install diff_match_patch_python
    pip install pdf-diff

    It works like a charm without any issue. readjfb your suggestions helped a lot in a pdf comparison project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions