facebookresearch / fairseq

Facebook AI Research Sequence-to-Sequence Toolkit written in Python.
MIT License
30.23k stars 6.38k forks source link

Unable to import simultaneous_translation. #3309

Closed SnoozingSimian closed 3 years ago

SnoozingSimian commented 3 years ago

I was trying to preprocess a text file using the script from fairseq_cli/preprocess.py on Google colabs, and I got the following error.

ModuleNotFoundError: No module named 'examples.simultaneous_translation'

Code

It is pretty simple, I installed fairseq on Google Colab and tried to use the preprocess.py script.

I had installed fairseq using

!git clone https://github.com/pytorch/fairseq
%cd fairseq
!pip install --editable ./
%cd ..

And then tried to run the aforementioned script on my text file

!python "fairseq/fairseq_cli/preprocess.py"  --only-source --trainpref "/content/text.txt"  --destdir "/content/cleaned" --thresholdsrc 10 --padding-factor 1 --workers 16 --nwordstgt 200000

What have you tried?

To see if everything was in order I tried simply importing simultaneous_translation as follows

from fairseq.examples import simultaneous_translation

Which also gave me same the error

ModuleNotFoundError: No module named 'examples.simultaneous_translation'

Environment

SnoozingSimian commented 3 years ago

I was able to solve this by doing a simple !pip install fairseq and then cloning the repo afterwards as mentioned here. Closing this issue.