anhaidgroup / deepmatcher

Python package for performing Entity and Text Matching using Deep Learning.
BSD 3-Clause "New" or "Revised" License
565 stars 130 forks source link

ModuleNotFoundError: No module named 'torchtext.legacy' #96

Closed jacobceles closed 2 years ago

jacobceles commented 2 years ago

Hi,

When trying to import deepmatcher, I am facing the error: ModuleNotFoundError: No module named 'torchtext.legacy'

Steps to recreate:

!pip install deepmatcher --user
import deepmatcher as dm

Stacktrace:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-4-e017bad088ef> in <module>
----> 1 import deepmatcher as dm

~/.local/lib/python3.8/site-packages/deepmatcher/__init__.py in <module>
      8 import sys
      9 
---> 10 from .data import process as data_process
     11 from .models import modules
     12 from .models.core import (MatchingModel, AttrSummarizer, WordContextualizer,

~/.local/lib/python3.8/site-packages/deepmatcher/data/__init__.py in <module>
----> 1 from .field import MatchingField, reset_vector_cache
      2 from .dataset import MatchingDataset
      3 from .iterator import MatchingIterator
      4 from .process import process, process_unlabeled
      5 from .dataset import split

~/.local/lib/python3.8/site-packages/deepmatcher/data/field.py in <module>
     11 import fasttext
     12 import torch
---> 13 from torchtext.legacy import data, vocab
     14 from torchtext.utils import download_from_url
     15 from urllib.request import urlretrieve

ModuleNotFoundError: No module named 'torchtext.legacy'

Please let me know how to fix this, or if you need more information.

sidharthms commented 2 years ago

Ah this is likely because the latest version of torchtext may have removed the legacy module. I'll fix the install dependencies to correct it. In the meantime, you could try reverting torchtext to an older release manually for now.

On Tue, Apr 19, 2022, 8:11 AM Jacob Celestine @.***> wrote:

Hi,

When trying to import deepmatcher, I am facing the error: ModuleNotFoundError: No module named 'torchtext.legacy'

Steps to recreate:

!pip install deepmatcher --user import deepmatcher as dm

Stacktrace:


ModuleNotFoundError Traceback (most recent call last)

in ----> 1 import deepmatcher as dm ~/.local/lib/python3.8/site-packages/deepmatcher/__init__.py in 8 import sys 9 ---> 10 from .data import process as data_process 11 from .models import modules 12 from .models.core import (MatchingModel, AttrSummarizer, WordContextualizer, ~/.local/lib/python3.8/site-packages/deepmatcher/data/__init__.py in ----> 1 from .field import MatchingField, reset_vector_cache 2 from .dataset import MatchingDataset 3 from .iterator import MatchingIterator 4 from .process import process, process_unlabeled 5 from .dataset import split ~/.local/lib/python3.8/site-packages/deepmatcher/data/field.py in 11 import fasttext 12 import torch ---> 13 from torchtext.legacy import data, vocab 14 from torchtext.utils import download_from_url 15 from urllib.request import urlretrieve ModuleNotFoundError: No module named 'torchtext.legacy' Please let me know how to fix this, or if you need more information. — Reply to this email directly, view it on GitHub , or unsubscribe . You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
jacobceles commented 2 years ago

Thanks! For now, I am using the 0.11.0 version of torchtext. Moving to 0.12.0 seems to cause the issue. Please close the issue when you have made the required changes to the code.

alexharvey commented 2 years ago

Hi @jacobceles - how did you go about this. I don't see that there is a 0.11.0 available?

$ pip index versions torchtext
WARNING: pip index is currently an experimental command. It may be removed/changed in a future release without prior warning.
torchtext (0.12.0)
Available versions: 0.12.0, 0.6.0, 0.5.0, 0.4.0, 0.3.1, 0.2.3, 0.2.1, 0.2.0, 0.1.1

Looks like there is a PR to update torch pending. I'd like work with deepmatcher in the meantime though.

sidharthms commented 2 years ago

You should be able to install version 0.11 I believe: https://pypi.org/project/torchtext/#history

On Sun, May 29, 2022, 9:42 AM Alex Harvey @.***> wrote:

Hi @jacobceles https://github.com/jacobceles - how did you go about this. I don't see that there is a 0.11.0 available?

$ pip index versions torchtext WARNING: pip index is currently an experimental command. It may be removed/changed in a future release without prior warning. torchtext (0.12.0) Available versions: 0.12.0, 0.6.0, 0.5.0, 0.4.0, 0.3.1, 0.2.3, 0.2.1, 0.2.0, 0.1.1

Looks like there is a PR to update torch pending. I'd like work with deepmatcher in the meantime though.

— Reply to this email directly, view it on GitHub https://github.com/anhaidgroup/deepmatcher/issues/96#issuecomment-1140484611, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABWE5ZO3QOVUQ3XEYMFJK3DVMOM7NANCNFSM5TZFPG3A . You are receiving this because you commented.Message ID: @.***>

jacobceles commented 2 years ago

@alexharvey That's weird. Perhaps because of the hardware that you are using? I used Google Colab (Linux-based) and just installed it using pip:

Screen Shot 2022-05-30 at 9 38 08 AM
alexharvey commented 2 years ago

I was trying on an M1 MacBook but I'll now just switch and try on Colab. Thanks!

jacobceles commented 2 years ago

Oh okay, that makes sense. M1 Mac still has compatibility issues with PyTorch. Infact, I faced the same issue you are having before, and so switched to Colab.

paularpan1135 commented 1 year ago

This still doesn't work for me, reverting to torchtext 0.11.0 gives me a AttributeError: module 'torchtext.data' has no attribute 'Field'

Maubald commented 9 months ago

@alexharvey That's weird. Perhaps because of the hardware that you are using? I used Google Colab (Linux-based) and just installed it using pip:

Screen Shot 2022-05-30 at 9 38 08 AM

Hello, for me is not working neither on Colab. Do you know any suggestion on how to make it work? Thanks in advance.