AttributeError: module 'torchtext.data' has no attribute 'Field'
I want to run a git project used pytorch and torchtext but when I run it, it raise error:
  File &quot;main.py&quot;, line 60, in &lt;module&gt;
    main()
  File &quot;main.py&quot;, line 50, in main
    train_iters, dev_iters, test_iters, vocab = load_dataset(config)
  File &quot;/home/esmailza/style transfer/style-transformer/data.py&quot;, line 23, in load_dataset
    TEXT = data.Field(batch_first=True, eos_token='&lt;eos&gt;')
AttributeError: module 'torchtext.data' has no attribute 'Field'

torch version  = 1.8.0
torchtext version = 0.9

def load_dataset(config, train_pos='train.pos', train_neg='train.neg',
                 dev_pos='dev.pos', dev_neg='dev.neg',
                 test_pos='test.pos', test_neg='test.neg'):

    root = config.data_path
    TEXT = data.Field(batch_first=True, eos_token='&lt;eos&gt;')
    
    dataset_fn = lambda name: data.TabularDataset(
        path=root + name,
        format='tsv',
        fields=[('text', TEXT)]
    )


From TorchText 0.9.0 Release Notes

torchtext.data.Field -&gt; torchtext.legacy.data.Field
This means, all features are still available, but within torchtext.legacy instead of torchtext.

torchtext.data.Field has been moved to torchtext.legacy.data.Field

And the imports would change this way:
from torchtext.legacy import data

