OpenNMT Forum

Attribute lookup Field.<lambda> on torchtext.data.field failed

I use conda and I try to install openNMT-py
I install torchtext version 0.4.0 But the error is occur whte i try to preprocess the data.
Of course I try pip install -r requirements.txt and setup.
also try conda install ~~

command :

python3 preprocess.py -train_src data/src-train.txt -train_tgt data/tgt-train.txt -valid_src data/src-val.txt -valid_tgt data/tgt-val.txt -save_data data/demo

Error

Traceback (most recent call last):
File “preprocess.py”, line 218, in
main(opt)
File “preprocess.py”, line 199, in main
‘train’, fields, src_reader, tgt_reader, opt)
File “preprocess.py”, line 142, in build_save_dataset
torch.save(fields, vocab_path)
File “/home/chanjun_park/miniconda3/envs/WAT/lib/python3.6/site-packages/torch/serialization.py”, line 209, in save
return _with_file_like(f, “wb”, lambda f: _save(obj, f, pickle_module, pickle_protocol))
File “/home/chanjun_park/miniconda3/envs/WAT/lib/python3.6/site-packages/torch/serialization.py”, line 134, in _with_file_like
return body(f)
File “/home/chanjun_park/miniconda3/envs/WAT/lib/python3.6/site-packages/torch/serialization.py”, line 209, in
return _with_file_like(f, “wb”, lambda f: _save(obj, f, pickle_module, pickle_protocol))
File “/home/chanjun_park/miniconda3/envs/WAT/lib/python3.6/site-packages/torch/serialization.py”, line 282, in _save
pickler.dump(obj)
_pickle.PicklingError: Can’t pickle <function Field. at 0x7fed4f81e950>: attribute lookup Field. on torchtext.data.field failed

Hello! @park

I remember I got this issue on one of my machines, but did not have a note. I think it was about the Torch version. What is the Torch version you have? When in trouble, the easiest way to install Torch was following the provided command at: https://pytorch.org/ - scroll down, select your system specifications and use the command.

Kind regards,
Yasmin

Thank you !! I solve the problem!!
when i command pip install --upgrade -r requirements.txt