sheffieldnlp/naacl2018-fever

ImportError: cannot import name 'Dataset'

Closed this issue · 3 comments

When I trained the Decomposable Attention model, I got the bug:

File "src/scripts/rte/da/train_da.py", line 9, in <module>
    from allennlp.data import Vocabulary, Dataset, DataIterator, DatasetReader, Tokenizer, TokenIndexer
ImportError: cannot import name 'Dataset'

I installed allennlp from source and when I looked into the folder data, there's nothing called Dataset. Does anybody know how to fix this problem? Thanks!

j6mes commented

Hi, if you're installing allennlp from source, you'd need to select version 0.2.3 as I think in later versions, they cease to use the Dataset class.

I'd recommend using pip to manage the dependencies.

Hope this helps

When I tried to install via pip3 allennlp==0.2.3, I kept getting this message:

sanic-plugins-framework 0.5.2.dev20180201 has requirement sanic>=0.7.0, but you'll have sanic 0.6.0 which is incompatible.
sanic-cors 0.9.4 has requirement sanic>=0.7.0, but you'll have sanic 0.6.0 which is incompatible.
Installing collected packages: sanic-plugins-framework, sanic-cors
Successfully installed sanic-cors-0.9.4 sanic-plugins-framework-0.5.2.dev20180201

I looked into the setup.py and see the required packages are:

 install_requires=[
          'pyhocon==0.3.35',
          'typing',
          'overrides',
          'nltk',
          'spacy',
          'numpy',
          'pillow',
          'tensorboard-pytorch',
          'cffi==1.11.2',
          'awscli>=1.11.91',
          'sanic==0.6.0',
          'sanic-cors',
          'argparse',
          'requests>=2.18',
          'tqdm',
          'editdistance',
          'jupyter'
      ]

Apparently, the newest version of sanic-cors conflits with sanic==0.6.0. Does anyone know how to fix this problem? Thanks a lot!

j6mes commented

Hi Chip,

Yes, DrQA and AllenNLP have conflicting packages - this isn't an issue as I don't use spacy or sanic in this implantation.

I think the issue is that I didn't specify the PyTorch version in the instructions. It must be 0.3.1 (which was latest at time of publication) - the latest version introduces breaking changes).

I've updated the instructions and re-ran the setup and it works for me.

Note that this is not designed to run on Windows OSs.

Hope this helps - James