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

[Bug Report] Cannot create any env, TypeError: 'NoneType' object is not subscriptable #292

Closed
sparisi opened this issue Dec 20, 2022 · 2 comments

Comments

@sparisi
Copy link
Contributor

sparisi commented Dec 20, 2022

Just installed this repo with pip install minigrid. Using python 3.10.9 on Win 11.

import gymnasium
gymnasium.make('MiniGrid-Unlock-v0')

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\xxx\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\gymnasium\core.py", line 383, in __repr__
    return str(self)
  File "C:\Users\xxx\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\gymnasium\core.py", line 379, in __str__
    return f"<{type(self).__name__}{self.env}>"
  File "C:\Users\xxx\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\gymnasium\core.py", line 379, in __str__
    return f"<{type(self).__name__}{self.env}>"
  File "C:\Users\xxx\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\minigrid\minigrid_env.py", line 207, in __str__
    if i == self.agent_pos[0] and j == self.agent_pos[1]:
TypeError: 'NoneType' object is not subscriptable

This happens with any env I tried except the empty minigrid.

I have checked that there is no similar issue in the repo.

@pseudo-rnd-thoughts
Copy link
Member

pseudo-rnd-thoughts commented Dec 21, 2022

You don't have it in your example code but I think you are printing the environment.
Minigrid implements a different print function than gym where the print actually provides a string-based grid of the current environment.
Therefore, you should be able to solve this through just avoiding the print statement until you have reset the environment.

We should be able to raise a more helpful error so thanks for the issue

@sparisi
Copy link
Contributor Author

sparisi commented Dec 21, 2022

Oh right! This is the first time I use the new minigrid + gymnasium, and in the old gym_minigrid the env was just printed as a matrix of strings without problems. Anyway, I can run experiments and that's what matters. Thanks!

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