AttributeError:模块“torchtext.data”没有属性“Field”未用torchtext.legacy修复

问题描述 投票:0回答:1

我正在尝试使用 torchtext 中的 torchtext.data.Field() 但它无法以我尝试过的任何方式工作。

我尝试过

from torchtext.legacy import data
但似乎不起作用。我还尝试通过运行
pip install torchtext==0.10.0
安装另一个版本的 torchtext(当前有 0.16.2),但我在终端中收到此错误消息

ERROR: Could not find a version that satisfies the requirement torchtext==0.10.0 (from versions: 0.1.1, 0.2.0, 0.2.1, 0.2.3, 0.3.1, 0.4.0, 0.5.0, 0.6.0, 0.16.2)
ERROR: No matching distribution found for torchtext==0.10.0

以前有人遇到过这个错误吗?

我使用的是Python版本3.12.1的conda环境,我的torch版本是2.2.0。

python pytorch torchtext
1个回答
0
投票
支持

torchtext
直到
python 3.11

https://pypi.org/project/torchtext/

您需要降级到

python 3.11
或单独安装
python 3.11
才能使用
torchtext

© www.soinside.com 2019 - 2024. All rights reserved.