Text: ModuleNotFoundError: No module named 'torchtext.data.metrics'

Created on 28 Jun 2020  ยท  4Comments  ยท  Source: pytorch/text

โ“ Questions and Help

I was testing bleu_score in Google Colab note book and these were the precise steps taken;

!pip install torchtext

Requirement already satisfied: torchtext in /usr/local/lib/python3.6/dist-packages (0.3.1)
Requirement already satisfied: numpy in /usr/local/lib/python3.6/dist-packages (from torchtext) (1.18.5)
Requirement already satisfied: requests in /usr/local/lib/python3.6/dist-packages (from torchtext) (2.23.0)
Requirement already satisfied: torch in /usr/local/lib/python3.6/dist-packages (from torchtext) (1.5.1+cu101)
Requirement already satisfied: tqdm in /usr/local/lib/python3.6/dist-packages (from torchtext) (4.41.1)
Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.6/dist-packages (from requests->torchtext) (3.0.4)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.6/dist-packages (from requests->torchtext) (2020.6.20)
Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.6/dist-packages (from requests->torchtext) (2.9)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.6/dist-packages (from requests->torchtext) (1.24.3)
Requirement already satisfied: future in /usr/local/lib/python3.6/dist-packages (from torch->torchtext) (0.16.0)

import torch
from torchtext.data.metrics import bleu_score

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-10-ee5ca0897ab0> in <module>()
      1 import torch
----> 2 from torchtext.data.metrics import bleu_score

ModuleNotFoundError: No module named 'torchtext.data.metrics'

---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------
OPEN EXAMPLESSEARCH STACK OVERFLOW

Even after installing torchtext alone, module not found error is still there. Hoping to find a solution soon.

Most helpful comment

Thank you,
pip install torchtext==0.6.0 worked

All 4 comments

Can you check the version of the torchtext?

torchtext==0.3.1

It's too old. You should install our latest one 0.6.0.

Thank you,
pip install torchtext==0.6.0 worked

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Taekyoon picture Taekyoon  ยท  3Comments

aatkinson picture aatkinson  ยท  3Comments

felipebravom picture felipebravom  ยท  3Comments

david-waterworth picture david-waterworth  ยท  4Comments

shafiul picture shafiul  ยท  3Comments