AttributeError: 'module' object has no attribute 'float32'
I am trying to use OpenNMT-py with python 2.7. OpenNMT-py requires torchtext, so I installed it but now when I am running my program, I am getting the following error message.

Traceback (most recent call last):
  File "examples/StackPointerParser.py", line 23, in &lt;module&gt;
    from neuronlp2.io import get_logger, conllx_stacked_data
  File "./neuronlp2/__init__.py", line 7, in &lt;module&gt;
    from . import models
  File "./neuronlp2/models/__init__.py", line 4, in &lt;module&gt;
    from .parsing import *
  File "./neuronlp2/models/parsing.py", line 15, in &lt;module&gt;
    from onmt.modules import LayerNorm, Transformer
  File "/home/wasiahmad/software/anaconda2/lib/python2.7/site-packages/onmt/__init__.py", line 1, in &lt;module&gt;
    import onmt.io
  File "/home/wasiahmad/software/anaconda2/lib/python2.7/site-packages/onmt/io/__init__.py", line 1, in &lt;module&gt;
    from onmt.io.IO import collect_feature_vocabs, make_features, \
  File "/home/wasiahmad/software/anaconda2/lib/python2.7/site-packages/onmt/io/IO.py", line 8, in &lt;module&gt;
    import torchtext.data
  File "/home/wasiahmad/software/anaconda2/lib/python2.7/site-packages/torchtext/__init__.py", line 1, in &lt;module&gt;
    from . import data
  File "/home/wasiahmad/software/anaconda2/lib/python2.7/site-packages/torchtext/data/__init__.py", line 4, in &lt;module&gt;
    from .field import RawField, Field, ReversibleField, SubwordField, NestedField, LabelField
  File "/home/wasiahmad/software/anaconda2/lib/python2.7/site-packages/torchtext/data/field.py", line 61, in &lt;module&gt;
    class Field(RawField):
  File "/home/wasiahmad/software/anaconda2/lib/python2.7/site-packages/torchtext/data/field.py", line 115, in Field
    torch.float32: float,
AttributeError: 'module' object has no attribute 'float32'


I tried to look for a solution to resolve this issue but couldn't find any. Any help would be appreciated.

This is more a guess, as you have not given information about your version. But it seems to me that your torchtext version is not compatible with your PyTorch version. 

Probably when you installed torchtext you got the newer version already made for PyTorch 0.4.0. But your PyTorch version installed is still older than 0.4.0 (version 0.3.1 or so).

If that is the case you have two options. Downgrading torchtext to a version compatible to yours (probably the version before). Or upgrading PyTorch to version 0.4.0.

I hope this helps.
