Farama-Foundation / Miniworld

Simple and easily configurable 3D FPS-game-like environments for reinforcement learning
http://miniworld.farama.org/
Apache License 2.0
700 stars 131 forks source link

[Bug Report] Getting error: gym.error.NameNotFound: Environment doesn't exist. #80

Closed freyavs closed 1 year ago

freyavs commented 1 year ago

Hi, I'm not sure if this is a bug or if I'm doing something wrong, but I'm trying to use this project with the gym interface. I'm getting the following error

gym.error.NameNotFound: Environment MiniWorld-CollectHealth doesn't exist.

Code example

import gym
import gym_miniworld

env = gym.make("MiniWorld-CollectHealth-v0")

System Info

Additional context I did some logging, the environments get registered and are in the registry immediately afterwards. But then later, when calling gym.make, they are not in the registry anymore: 2022-12-07_17-32

I've tried the exact same workflow on a similar project, where it does work. So, not sure if this is a bug or what else to do here?

pseudo-rnd-thoughts commented 1 year ago

Could you try

import gym
import gym_miniworld

print(gym.envs.registry.keys())
env = gym.make("MiniWorld-CollectHealth-v0")

On a fresh install, gym contains the environment for me but raises an error related to pyglet instead of NameNotFound

freyavs commented 1 year ago

This is the result:

2022-12-08_13-10

For comparison, I'm trying the exact same with a similar project (memory maze), and there it does show the registered environments in this print. Also did a fresh install and still the same.

Edit: actually, with pip install and then import miniworld I'm not getting this error anymore, might be something with installing from source. But I am getting another error where /site-packages/miniworld/meshes/medkit.obj doesn't exist, not sure if this is because of broken pip install mentioned "You can install it from PyPI using (image broken do not use yet)".

freyavs commented 1 year ago

With installing via pip, I run into another problem. For running on a cluster, setting the PYOPENGL_PLATFORM environment does not seem to be working? (the alternative solution mentioned is not relevant for me)

PYOPENGL_PLATFORM=egl python3 your_script.py

I also tried this locally, and get the same error (in pyglet)

ValueError: Unknown OpenGL API: None

(running locally without setting this variable also gives an error because there's no /site-packages/miniworld/meshes/..)

pseudo-rnd-thoughts commented 1 year ago

@BolunDai0216 Would you be able to help with this?

BolunDai0216 commented 1 year ago

For your original problem (if installed from source), I think it is because we are currently moving to use gymnasium instead of gym.

Can you try

import gymnasium as gym
import gym_miniworld

env = gym.make("MiniWorld-CollectHealth-v0")

and see if that works?

If that still does not solve your issue, can you try running manual_control.py in the scripts directory and see if that is working?

freyavs commented 1 year ago

That solved most of the problems, thank you! I'm still seeing the ValueError: Unknown OpenGL API: None on my cluster, but I assume for pyglet to work the underlying OpenGL drivers etc. should be set up?

BolunDai0216 commented 1 year ago

Yes, I think OpenGL should be set up.