Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError: No module named 'attention' #2

Open
RoelVdP opened this issue Sep 27, 2018 · 2 comments
Open

ModuleNotFoundError: No module named 'attention' #2

RoelVdP opened this issue Sep 27, 2018 · 2 comments

Comments

@RoelVdP
Copy link

RoelVdP commented Sep 27, 2018

sudo apt install python-pip
pip install tensorflow
pip install dm-sonnet
pip install tqdm  
pip install numpy
git clone https://github.com/louishenrifranc/attention.git
cd attention
./run_micro_services.sh

Gives:

$ ./run_micro_services.sh 
Experiment will be run without saving current version of the code/config
Running Task Data Generation
Traceback (most recent call last):
  File "attention/services/create_copy_task/create_copy_task.py", line 1, in <module>
    from tqdm import trange
ModuleNotFoundError: No module named 'tqdm'
Run Task Data Generation
Run Attention Traininig
Traceback (most recent call last):
  File "attention/services/attention_train/attentiontrain.py", line 6, in <module>
    from attention.utils.config import AttrDict, RunConfig
ModuleNotFoundError: No module named 'attention'

So tried:

 sudo apt install python3-tqdm
 sudo apt install python3-numpy

But then get:

$ ./run_micro_services.sh 
Experiment will be run without saving current version of the code/config
Running Task Data Generation
Traceback (most recent call last):
  File "attention/services/create_copy_task/create_copy_task.py", line 9, in <module>
    from attention.utils.config import AttrDict
ModuleNotFoundError: No module named 'attention'
Run Task Data Generation
Run Attention Traininig
Traceback (most recent call last):
  File "attention/services/attention_train/attentiontrain.py", line 6, in <module>
    from attention.utils.config import AttrDict, RunConfig
ModuleNotFoundError: No module named 'attention'

OS: Ubuntu Bionic.
Any ideas?

@RoelVdP
Copy link
Author

RoelVdP commented Sep 27, 2018

cp attention/utils/config.py ./attention/services/create_copy_task/
cp attention/utils/config.py ./attention/services/attention_train/

and change attention/services/create_copy_task/create_copy_task.py to:

from config import AttrDict

and similar change to attention/services/attention_train/attentiontrain.py
and similar copy/change for other things reference from top of attentiontrain.py
etc.
It may end up working that way, but it's hacky.

@RoelVdP
Copy link
Author

RoelVdP commented Sep 27, 2018

Found a solution here (the problem is python 3 compatibility):
https://stackoverflow.com/questions/45415473/importing-module-from-sub-directory-works-in-python-2-but-not-python-3

Patch that will fix this;

# git diff
diff --git a/run_micro_services.sh b/run_micro_services.sh
old mode 100644
new mode 100755
index 26a615d..96ab557
--- a/run_micro_services.sh
+++ b/run_micro_services.sh
@@ -1,5 +1,7 @@
 #!/usr/bin/env bash
 
+export PYTHONPATH=${PWD}
+
 OUTPUT_DIR="transformer_output"
 TASK_CONFIG="attention/services/create_copy_task/default_config.json"
 METADATA="attention/services/attention_train/default_metadata.json"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant