我在处理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发布于 2021-10-21 07:17:22
如果您使用的是源代码文件,可以尝试删除此文件并运行命令:
pip install torchtexthttps://stackoverflow.com/questions/66026492
复制相似问题