question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ModuleNotFoundError: No module named 'examples.simultaneous_translation'

See original GitHub issue

🐛 Bug

Performing transfer learning using Roberta by following the custom classification readme in the Examples directory of Roberta. This code was working up to 1 week ago and now gives an error: ModuleNotFoundError: No module named ‘examples.simultaneous_translation’

Steps to reproduce the behavior:


fairseq-preprocess \
    --only-source \
    --trainpref "/content/Task1a/train.input0.bpe" \
    --validpref "/content/Task1a/val.input0.bpe" \
    --destdir "/content/Task1a-bin/input0" \
    --workers 60 \
    --srcdict dict.txt

fairseq-preprocess \
    --only-source \
    --trainpref "/content/Task1a/train.label" \
    --validpref "/content/Task1a/val.label" \
    --destdir "/content/Task1a-bin/label" \
    --workers 60
  1. Traceback:
--2021-02-28 05:54:18--  https://dl.fbaipublicfiles.com/fairseq/gpt2_bpe/dict.txt
Resolving dl.fbaipublicfiles.com (dl.fbaipublicfiles.com)... 104.22.75.142, 172.67.9.4, 104.22.74.142, ...
Connecting to dl.fbaipublicfiles.com (dl.fbaipublicfiles.com)|104.22.75.142|:443... connected.
HTTP request sent, awaiting response... 304 Not Modified
File ‘dict.txt’ not modified on server. Omitting download.

Traceback (most recent call last):
  File "/usr/local/bin/fairseq-preprocess", line 33, in <module>
    sys.exit(load_entry_point('fairseq', 'console_scripts', 'fairseq-preprocess')())
  File "/usr/local/bin/fairseq-preprocess", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/usr/local/lib/python3.7/dist-packages/importlib_metadata/__init__.py", line 100, in load
    module = import_module(match.group('module'))
  File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/content/fairseq/fairseq_cli/preprocess.py", line 18, in <module>
    from fairseq import options, tasks, utils
  File "/content/fairseq/fairseq/__init__.py", line 32, in <module>
    import fairseq.criterions  # noqa
  File "/content/fairseq/fairseq/criterions/__init__.py", line 36, in <module>
    importlib.import_module("fairseq.criterions." + file_name)
  File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/content/fairseq/fairseq/criterions/label_smoothed_cross_entropy_latency_augmented.py", line 6, in <module>
    from examples.simultaneous_translation.utils.latency import LatencyTraining
ModuleNotFoundError: No module named 'examples.simultaneous_translation'
Traceback (most recent call last):
  File "/usr/local/bin/fairseq-preprocess", line 33, in <module>
    sys.exit(load_entry_point('fairseq', 'console_scripts', 'fairseq-preprocess')())
  File "/usr/local/bin/fairseq-preprocess", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/usr/local/lib/python3.7/dist-packages/importlib_metadata/__init__.py", line 100, in load
    module = import_module(match.group('module'))
  File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/content/fairseq/fairseq_cli/preprocess.py", line 18, in <module>
    from fairseq import options, tasks, utils
  File "/content/fairseq/fairseq/__init__.py", line 32, in <module>
    import fairseq.criterions  # noqa
  File "/content/fairseq/fairseq/criterions/__init__.py", line 36, in <module>
    importlib.import_module("fairseq.criterions." + file_name)
  File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/content/fairseq/fairseq/criterions/label_smoothed_cross_entropy_latency_augmented.py", line 6, in <module>
    from examples.simultaneous_translation.utils.latency import LatencyTraining
ModuleNotFoundError: No module named 'examples.simultaneous_translation'

Expected behavior

Expected to save the preprocessed and tokenized input and labels for training

Environment

  • fairseq Version (master):
  • Google Colab

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:5
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
wesleywtcommented, Mar 18, 2021

Adding fairseq to the PYTHONPATH solved the problem for me. I got the solution from this issue

cd /content 
!echo $PYTHONPATH

import os

os.environ['PYTHONPATH'] += ":/content/fairseq/" #path to your fairseq 

!echo $PYTHONPATH
6reactions
RSid8commented, Mar 3, 2021

@lematt1991 I did try that but it failed to work. However, I did a regular

!pip install fairseq

and cloned the repository after. This caused the error to stop appearing. @KirillKonovalov that might be helpful to you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ModuleNotFoundError: No module named 'examples ... - GitHub
This code was working up to 1 week ago and now gives an error: ModuleNotFoundError: No module named 'examples.simultaneous_translation'.
Read more >
ModuleNotFoundError: No module named 'examples'
Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'examples' How to remove the ModuleNot.
Read more >
OpenNMT/OpenNMT-py - Gitter
I try to execute the preprocess part but it throws an error "No module named 'onmt.bin.preprocess'" and if i installed the omnt then...
Read more >
How to Fix ModuleNotFoundError (No Module Named) Error ...
in a virtual environment or using Python 2pip install numpy# 👇️ for python 3 (could also be pip3.10 depending on your version)pip3 install ......
Read more >
Using Language Interpretation in your meeting or webinar
Local recordings of interpretation sessions will record any audio the person recording can hear, but not multiple audio channels.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found