카테고리 없음

torchtext import error "Field"

Roiei 2021. 9. 11. 10:25
반응형

If you see the following error when trying to import Field of torchtext.data

ImportError: cannot import name 'Field' from 'torchtext.data' (C:\Users\royvi\anaconda3\envs\nlp\lib\site-packages\torchtext\data\__init__.py)

 

This error happens by using the later version of torchtext.

Field will be deprecated, so in order to use this one, 

you need to add 'legacy' in the middle of path like this.

from torchtext.legacy.data import Field

 

반응형