---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-25-b2b2b2ad7bcb> in <cell line: 12>()
10 from torch.utils.data import Dataset, DataLoader
11
---> 12 import pytorch_lightning as pl
13 import seaborn as sns
14 from pylab import rcParams
13 frames
/usr/local/lib/python3.9/dist-packages/torchtext/legacy/data/dataset.py in <module>
11 from torchtext.data.utils import RandomShuffler
12 from .example import Example
---> 13 from torchtext.utils import download_from_url, unicode_csv_reader
14
15
ImportError: cannot import name 'unicode_csv_reader' from 'torchtext.utils' (/usr/local/lib/python3.9/dist-packages/torchtext/utils.py)
---------------------------------------------------------------------------
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.
---------------------------------------------------------------------------
我正在实现一个youtube视频教程。我也这样做,但它不起作用
https://www.youtube.com/watch?v=PCgrgHgy26c
Torch :1.8.1 texttorch:0.9.1 Pytroch-lightning:1.2.6
请帮助我了解问题:(
1条答案
按热度按时间3mpgtkmj1#
问题出在你的torchtext版本上。
函数
unicode_csv_reader
在torchtext的0.9.1版本中不再可用。要读取unicode编码的csv,你可以使用csv库,使用utf-8编码的
open
打开你的csv文件,然后加载你的数据。