前言
安装torchtext总是出错,他与torch版本对不上,或自己版本有问题使得Dataset等函数不能用。
安装torch1.3.0 + torchvision0.4.1+cpu + torchtext==0.4.0 就可使用了
步骤
1.安装包
代码如下(示例):
# CPU版本安装:
pip install torch==1.3.0+cpu torchvision==0.4.1+cpu -f https://download.pytorch.org/whl/torch_stable.html
# GPU版本安装:(默认是CUDA10版本)
pip install torch===1.3.0 torchvision===0.4.1 -f https://download.pytorch.org/whl/torch_stable
pip install torchtext==0.4.0
2.引入库
代码如下(示例):
from torchtext.data import Dataset