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

TypeError when calling marlo.make() with marlo environments #27

Open
douglasrizzo opened this issue Aug 10, 2018 · 5 comments
Open

TypeError when calling marlo.make() with marlo environments #27

douglasrizzo opened this issue Aug 10, 2018 · 5 comments

Comments

@douglasrizzo
Copy link

Hi everyone. I have installed Malmo under Manjaro Linux and Python 3.5. I was able to run Minecraft and the examples that come with Malmo. However, after installing MarLo, I tried to run examples like single_agent.py and test.py, as well as the example in the README, but every time marlo.make(...) was called I got the following error: TypeError: join() argument must be str or bytes, not 'PosixPath'.

The following code reproduces my error:

import marlo
client_pool = marlo.launch_clients(1)  # this works!

# this throws an error
join_tokens = marlo.make('MarLo-MazeRunner-v0',
                         params={ "client_pool": client_pool })

I realized marlo depends on gym, so I tried to run some gym environments and they worked. I also passed the wrong name for an environment. like MarLo-MazeRunner-v1 or senseless-test-v0 and the error was different, which makes me believe an exception only occurs when trying to load a marlo environment. Any thoughts?

@spMohanty
Copy link
Member

@douglasrizzo : gym.make and marlo.make have different behaviours internally.
But ideally MarLo-MazeRunner-v0 should work.

Did you use the Anaconda environments provided ?

conda install -c crowdai malmo

Also can you paste the complete stacktrace ?

@douglasrizzo
Copy link
Author

douglasrizzo commented Aug 10, 2018

Hi @spMohanty . I am not using the Anaconda installation. I followed the steps described in the installation page telling users to set their MALMO_MINECRAFT_ROOT and MALMO_XSD_PATH environment variables accordingly.

I will try to run it with Anaconda is necessary, but I already have 3 versions of Python installed locally, so I'd like to avoid installing another one if possible.

Here is my stack trace. I used Python 3.5.5, since Malmo has no support for Python 3.6 on Linux.

$ import marlo
$ join_tokens = marlo.make('MarLo-MazeRunner-v0',
                         params={"client_pool" : marlo.launch_clients(1)})


Nothing is listening on port 57769 - will attempt to launch Minecraft from a new terminal.
Giving Minecraft some time to launch... 
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ok
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-3-85914dd9009f> in <module>()
      1 join_tokens = marlo.make('MarLo-MazeRunner-v0',
----> 2                           params={"client_pool" : marlo.launch_clients(1)})
      3 
      4 

/usr/lib/python3.5/site-packages/marlo/__init__.py in make(env_key, params)
     87         env = gym.make("MarLo-RawXMLEnv-v0")
     88     else:
---> 89         env = gym.make(env_key)
     90     join_tokens = env.init(params, dry_run=True)
     91     return join_tokens

/usr/lib/python3.5/site-packages/gym/envs/registration.py in make(id)
    165 
    166 def make(id):
--> 167     return registry.make(id)
    168 
    169 def spec(id):

/usr/lib/python3.5/site-packages/gym/envs/registration.py in make(self, id)
    117         logger.info('Making new env: %s', id)
    118         spec = self.spec(id)
--> 119         env = spec.make()
    120         # We used to have people override _reset/_step rather than
    121         # reset/step. Set _gym_disable_underscore_compat = True on

/usr/lib/python3.5/site-packages/gym/envs/registration.py in make(self)
     81 
     82         elif callable(self._entry_point):
---> 83             env = self._entry_point()
     84         else:
     85             cls = load(self._entry_point)

/usr/lib/python3.5/site-packages/marlo/envs/MazeRunner/main.py in __init__(self, extra_params)
     17                 templates_folder = os.path.join(
     18                             Path(__file__).parent,
---> 19                             "templates"
     20                 )
     21         )

/usr/lib/python3.5/posixpath.py in join(a, *p)
     87                 path += sep + b
     88     except (TypeError, AttributeError, BytesWarning):
---> 89         genericpath._check_arg_types('join', a, *p)
     90         raise
     91     return path

/usr/lib/python3.5/genericpath.py in _check_arg_types(funcname, *args)
    141         else:
    142             raise TypeError('%s() argument must be str or bytes, not %r' %
--> 143                             (funcname, s.__class__.__name__)) from None
    144     if hasstr and hasbytes:
    145         raise TypeError("Can't mix strings and bytes in path components") from None

TypeError: join() argument must be str or bytes, not 'PosixPath'

@douglasrizzo
Copy link
Author

I followed the Anaconda installation instructions now. It worked, but I had to swap lines 3 and 4 and call conda activate marlo before conda install -c crowdai malmo, probably to install the environment dependencies inside the marlo environment. Couldn't get it to work on native Python, though.

@spMohanty
Copy link
Member

@douglasrizzo : Thanks for confirming. And yes, lines 3 and 4 should be swapped.

And yes we know about the issues with native python. We will be releasing more consistent wheels in a few days, and hopefully things will be more consistent then.

@AndKram
Copy link
Collaborator

AndKram commented Sep 5, 2018

Previous to Python 3.6 os.join could not accept Path objects. The "main.py" of each env could be changed to:
"""
def init(self, extra_params={}):
super(MarloEnvBuilder, self).init(
templates_folder = os.path.join(
str(Path(file).parent),
"templates"
)
)
self.params = self._default_params()

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

3 participants