前提
google colaboratoryでライブラリのtorchtextを入れたいのですが、サンプルコードの指示通りに入力してもエラーが発生してしまいます。
この解決策をどなたか教えていただけないでしょうか?
初歩的な質問で恐縮ですが、よろしくお願いします。
実現したいこと
torchtextをインポートしたい。
発生している問題・エラーメッセージ
--------------------------------------------------------------------------- ModuleNotFoundError Traceback (most recent call last) <ipython-input-8-78aa063f2c95> in <module> 2 3 # torchtextのバージョンアップに伴い、legacyを付ける必要あり ----> 4 from torchtext.legacy import data 5 6 # 入力データ ModuleNotFoundError: No module named 'torchtext.legacy' --------------------------------------------------------------------------- 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. ---------------------------------------------------------------------------
該当のソースコード
from torchtext.legacy import data
試したこと
torchtextのバージョンを変更してみたのですが、解決されませんでした。
補足情報(FW/ツールのバージョンなど)
以下記事通り
torchのバージョン-->1.11.0
それに合わせて
!pip install --upgrade torchtext==0.12.0
でtorchtextのバージョンを変えました。
> ModuleNotFoundError: No module named 'torchtext.legacy'
> !pip install --upgrade torchtext==0.12.0
legacyは、0.12からなくなりました
https://github.com/pytorch/text/tree/v0.11.2/torchtext
https://github.com/pytorch/text/tree/v0.12.0/torchtext
pytorch 1.10.1, torchtext 0.11.2あたりを入れたら動くのではないですかね
