facebookresearch / craftassist

A virtual assistant bot in Minecraft
MIT License
611 stars 78 forks source link

ModuleNotFoundError: No module named 'base_agent' #32

Closed 837liu closed 4 years ago

837liu commented 4 years ago

I'm on an Ubuntu 18.04 system.

In both the Docker and the local setup, when I get to this part:

_python ./python/craftassist/craftassistagent.py

I get the same stack dump:

_root@1706ae62edc6:/craftassist# python ./python/craftassist/craftassist_agent.pyTraceback (most recent call last): File "./python/craftassist/craftassist_agent.py", line 21, in import mc_memory File "/craftassist/python/craftassist/mc_memory.py", line 10, in import dance File "/craftassist/python/craftassist/dance.py", line 8, in import tasks File "/craftassist/python/craftassist/tasks.py", line 17, in import search File "/craftassist/python/craftassist/search.py", line 11, in import util File "/craftassist/python/craftassist/util.py", line 16, in import base_agent.rotation as rotation ModuleNotFoundError: No module named 'baseagent'

I'll try on a Docker for Windows environment next to see if it's reproducible there as well.

837liu commented 4 years ago

Replicated the error on Dockers for Window on a Win10 system.

837liu commented 4 years ago

Adding:

import os,sys,inspect currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) parentdir = os.path.dirname(currentdir) sys.path.insert(0,parentdir)

to _python/craftassist/baseagent/util.py so that util.py can import from _baseagent a level up seems to have fixed the problem, but I don't know the code structure well enough to know if this is an appropriate fix.

markperez1904 commented 4 years ago

I'm also getting the same error on Ubuntu 18.04, but I'm unable to implement the workaround from @837liu because for me, the util.py file is actually under /craftassist/python/base_agent.

Regardless, adding the 4 lines of python code didn't resolve this.

UPDATE: I pasted the 4 lines of python code right at the beginning of the file, and the bot worked!

snyxan commented 4 years ago

Hi @837liu & @markperez1904,

Thanks for pointing this out! We've fixed this bug in #33.

The issue is automatically closed after the PR is merged. But please try it out and feel free to post any relevant questions if any.