nusnlp / mlconvgec2018

Code and model files for the paper: "A Multilayer Convolutional Encoder-Decoder Neural Network for Grammatical Error Correction" (AAAI-18).
GNU General Public License v3.0
185 stars 73 forks source link

ImportError: cannot import name 'libbleu' from 'fairseq' #31

Closed Young1993 closed 4 years ago

Young1993 commented 4 years ago

Hi. When I ran ./run.sh I got an error below. I saw other guys faced the same problem, but their python version is 3.6, my python version is 3.7.2 so pls help me!

Here is what I put ./run.sh data/test/conll14st-test/conll14st-test.tok.src test 0 models/mlconv/model1.pt

and the error happens just like this ++ source paths.sh +++++ dirname paths.sh ++++ cd . ++++ pwd +++ BASE_DIR=/Volumes/SHIMIN/research/mlconvgec2018 +++ DATA_DIR=/Volumes/SHIMIN/research/mlconvgec2018/data +++ MODEL_DIR=/Volumes/SHIMIN/research/mlconvgec2018/models +++ SCRIPTS_DIR=/Volumes/SHIMIN/research/mlconvgec2018/scripts +++ SOFTWARE_DIR=/Volumes/SHIMIN/research/mlconvgec2018/software ++ '[' 4 -ge 4 ']' ++ input_file=data/test/conll14st-test/conll14st-test.tok.src ++ output_dir=test ++ device=0 ++ model_path=models/mlconv/model1.pt ++ '[' 4 -eq 6 ']' ++ [[ -d models/mlconv/model1.pt ]] ++ [[ -f models/mlconv/model1.pt ]] ++ models=models/mlconv/model1.pt ++ FAIRSEQPY=/Volumes/SHIMIN/research/mlconvgec2018/software/fairseq-py ++ NBEST_RERANKER=/Volumes/SHIMIN/research/mlconvgec2018/software/nbest-reranker ++ beam=12 ++ nbest=12 ++ threads=12 ++ mkdir -p test ++ /Volumes/SHIMIN/research/mlconvgec2018/scripts/apply_bpe.py -c /Volumes/SHIMIN/research/mlconvgec2018/models/bpe_model/train.bpe.model ++ CUDA_VISIBLE_DEVICES=0 ++ python3 /Volumes/SHIMIN/research/mlconvgec2018/software/fairseq-py/generate.py --no-progress-bar --path models/mlconv/model1.pt --beam 12 --nbest 12 --interactive --workers 12 /Volumes/SHIMIN/research/mlconvgec2018/models/data_bin ERROR: missing libbleu.so. run python setup.py install Traceback (most recent call last): File "/Volumes/SHIMIN/research/mlconvgec2018/software/fairseq-py/generate.py", line 13, in from fairseq import bleu, options, utils, tokenizer File "/Volumes/SHIMIN/research/mlconvgec2018/software/fairseq-py/fairseq/bleu.py", line 18, in raise e File "/Volumes/SHIMIN/research/mlconvgec2018/software/fairseq-py/fairseq/bleu.py", line 14, in from fairseq import libbleu ImportError: cannot import name 'libbleu' from 'fairseq' (/Volumes/SHIMIN/research/mlconvgec2018/software/fairseq-py/fairseq/init.py)

I tried to download the latest version of fairseq-py, but the error exists with no change.

thanks for help!

neverneverendup commented 4 years ago

Have you ever build fairseq-py using 'python setup.py build'? I got the same error as yours before. I think the version of this code is too old to replicate somehow.

Young1993 commented 4 years ago

Have you ever build fairseq-py using 'python setup.py build'? I got the same error as yours before. I think the version of this code is too old to replicate somehow.

I have no choice but downgrade the version which is the same as the author but I want to upgrade to higher python version

shamilcm commented 4 years ago

The repo is based on a much older version of Fairseq and python. You could just take the data preprocessing steps from this repo and then train models using. a more recent version of Fairseq that should work with Python 3.7: https://github.com/pytorch/fairseq and use the ConvS2S models.