ctallec / world-models

Reimplementation of World-Models (Ha and Schmidhuber 2018) in pytorch
MIT License
568 stars 131 forks source link

Data generation script: No module named 'utils' #20

Closed 0xsamgreen closed 5 years ago

0xsamgreen commented 5 years ago

During the data generation phase using the run command given in the readme, I'm getting an error during import of the utils package. This is because utils exists one level above generation_script.py.

$ python data/generation_script.py --rollouts 1000 --rootdir datasets/carracing --threads 1
xvfb-run -s "-screen 0 1400x900x24" --server-num=1 python data/carracing.py --dir datasets/carracing/thread_0 --rollouts 1001 --policy brown
Traceback (most recent call last):
  File "data/carracing.py", line 10, in <module>
    from utils.misc import sample_continuous_policy
ModuleNotFoundError: No module named 'utils'

I can get it to run with:

PYTHONPATH='.' python data/generation_script.py --rollouts 1000 --rootdir datasets/carracing --threads 1

Is everyone modifying their paths to get it to run?

AmazingAng commented 5 years ago

Yes, i encountered the same situation at beginning. The problem is in carracing.py in data folder. I think because it is in the sub-folder: data, it can not load library from another sub-folder: utils.misc. My solution is simple, copy the function sample_continuous_policy to carracing.py, instead of import the utils.misc library.

ctallec commented 5 years ago

I've just pushed a commit that should fix this. The fix is to use python -m data.carracing instead of python data/carracing.py in the subprocesses. Strangely enough, the previous version still works on my own computer. Can you tell me if you still have the error ?

JiahaoYao commented 5 years ago

I think that just solves the issue.