Error in 'from torchtext.data import Field, TabularDataset, BucketIterator, Iterator'
I am trying to implement this article https://towardsdatascience.com/bert-text-classification-using-pytorch-723dfb8b6b5b, but I have the following problem.
# Preliminaries
from torchtext.data import Field, TabularDataset, BucketIterator, Iterator

Error
ImportError: cannot import name 'Field' from 'torchtext.data' (/usr/local/lib/python3.7/dist-packages/torchtext/data/__init__.py)


OSError: /usr/local/lib/python3.7/dist-packages/torchtext/_torchtext.so: undefined symbol: _ZNK3c104Type14isSubtypeOfExtESt10shared_ptrIS0_EPSo


Try
from torchtext.legacy.data import Field, TabularDataset, BucketIterator, Iterator

Field is a legacy functionality of Torchtext since the 0.9 release. That article you linked was from before that release. If you've got the newest torchtext, but are trying to use legacy functionality, you need to use torchtext.legacy.*
Check out this tutorial for more info.
Also check this for full torchtext release notes.
