没有名为“torchtext._torchtext”的模块

时间:2021-02-03 11:22:02

标签: torch modulenotfounderror torchtext

我在使用 torctext 时出错:

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-65-e34e6e6439d5> in <module>
      1 import torch
      2 from torchtext.experimental.datasets.text_classification import TextClassificationDataset
----> 3 from torchtext.experimental.vocab import build_vocab_from_iterator
      4 from torchtext.data.utils import get_tokenizer
      5 from torchtext.experimental.functional import sequential_transforms, vocab_func, totensor

~\anaconda3\envs\env_pytorch\lib\site-packages\torchtext\experimental\vocab.py in <module>
      5 import torch
      6 import torch.nn as nn
----> 7 from torchtext._torchtext import (
      8     Vocab as VocabPybind,
      9     _load_vocab_from_file,

ModuleNotFoundError: No module named 'torchtext._torchtext'

我尝试将“torchtext”目录放入带有 jupiter notebook 的文件夹中,但错误再次发生

~\Desktop\Competition\VTB\Task 1\torchtext\experimental\transforms.py in <module>
      5 from collections import OrderedDict
      6 from torch import Tensor
----> 7 from torchtext._torchtext import SentencePiece as SentencePiecePybind
      8 import io
      9 

ModuleNotFoundError: No module named 'torchtext._torchtext

0 个答案:

没有答案