minerllabs / minerl

MineRL Competition for Sample Efficient Reinforcement Learning - Python Package
http://minerl.io/docs/
Other
685 stars 154 forks source link

help (failed to load class) #746

Closed JoHaYoung227 closed 7 months ago

JoHaYoung227 commented 7 months ago

Hello, I'm running on WSL2, I'm using Java version 8, and I've also changed the environment variables,

When I run the default code from the minerl GitHub, I get the following error. I would appreciate it if you could let me know how to solve it.


EOFError Traceback (most recent call last) Cell In[4], line 2 1 env = gym.make("MineRLBasaltBuildVillageHouse-v0") ----> 2 obs = env.reset() 4 done = False 5 while not done:

File ~/.local/lib/python3.10/site-packages/gym/wrappers/time_limit.py:27, in TimeLimit.reset(self, kwargs) 25 def reset(self, kwargs): 26 self._elapsed_steps = 0 ---> 27 return self.env.reset(**kwargs)

File ~/.local/lib/python3.10/site-packages/minerl/herobraine/env_specs/basalt_specs.py:78, in DoneOnESCWrapper.reset(self) 76 def reset(self): 77 self.episode_over = False ---> 78 return self.env.reset()

File ~/.local/lib/python3.10/site-packages/minerl/herobraine/env_specs/basalt_specs.py:57, in BasaltTimeoutWrapper.reset(self) 55 self.timeout = self.env.task.max_episode_steps 56 self.num_steps = 0 ---> 57 return super().reset()

File ~/.local/lib/python3.10/site-packages/gym/core.py:251, in Wrapper.reset(self, kwargs) 250 def reset(self, kwargs): --> 251 return self.env.reset(**kwargs)

File ~/.local/lib/python3.10/site-packages/minerl/env/_singleagent.py:22, in _SingleAgentEnv.reset(self) 21 def reset(self) -> Dict[str, Any]: ---> 22 multi_obs = super().reset() 23 return multi_obs[self.task.agent_names[0]]

File ~/.local/lib/python3.10/site-packages/minerl/env/_multiagent.py:436, in _MultiAgentEnv.reset(self) 433 agent_xmls = self._setup_agent_xmls(ep_uid) 435 # Start missing instances, quit episodes, and make socket connections --> 436 self._setup_instances() 438 # Episodic state variables 439 self.done = False

File ~/.local/lib/python3.10/site-packages/minerl/env/_multiagent.py:539, in _MultiAgentEnv._setupinstances(self) 537 for in range(num_instances_to_start): 538 instance_futures.append(tpe.submit(self._get_new_instance)) --> 539 self.instances.extend([f.result() for f in instance_futures]) 540 self.instances = self.instances[:self.task.agent_count] 541 # self.instances = [self._get_new_instance(port=12000)] 542 543 # Refresh old instances every N setups

File ~/.local/lib/python3.10/site-packages/minerl/env/multiagent.py:539, in (.0) 537 for in range(num_instances_to_start): 538 instance_futures.append(tpe.submit(self._get_new_instance)) --> 539 self.instances.extend([f.result() for f in instance_futures]) 540 self.instances = self.instances[:self.task.agent_count] 541 # self.instances = [self._get_new_instance(port=12000)] 542 543 # Refresh old instances every N setups

File /usr/lib/python3.10/concurrent/futures/_base.py:451, in Future.result(self, timeout) 449 raise CancelledError() 450 elif self._state == FINISHED: --> 451 return self.__get_result() 453 self._condition.wait(timeout) 455 if self._state in [CANCELLED, CANCELLED_AND_NOTIFIED]:

File /usr/lib/python3.10/concurrent/futures/_base.py:403, in Future.__get_result(self) 401 if self._exception: 402 try: --> 403 raise self._exception 404 finally: 405 # Break a reference cycle with the exception in self._exception 406 self = None

File /usr/lib/python3.10/concurrent/futures/thread.py:58, in _WorkItem.run(self) 55 return 57 try: ---> 58 result = self.fn(*self.args, **self.kwargs) 59 except BaseException as exc: 60 self.future.set_exception(exc)

File ~/.local/lib/python3.10/site-packages/minerl/env/_multiagent.py:805, in _MultiAgentEnv._get_new_instance(self, port, instance_id) 802 if InstanceManager.is_remote(): 803 launch_queue_logger_thread(instance, self.is_closed) --> 805 instance.launch(replaceable=self._is_fault_tolerant) 807 # Add a cleaning flag to the instance 808 instance.had_to_clean = False

File ~/.local/lib/python3.10/site-packages/minerl/env/malmo.py:427, in MinecraftInstance.launch(self, daemonize, replaceable) 425 error_str += spline + "\n" 426 # Throw an exception! --> 427 raise EOFError( 428 error_str + "\n\nMinecraft process finished unexpectedly. There was an error with Malmo.") 430 lines.append(line) 431 self._log_heuristic("\n".join(line.split("\n")[:-1]))

EOFError: /home/johy3943/.local/lib/python3.10/site-packages/minerl/env/../MCP-Reborn SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. [16:18:37] [Render thread/INFO]: Environment: authHost='https://authserver.mojang.com/', accountsHost='https://api.mojang.com/', sessionHost='https://sessionserver.mojang.com/', servicesHost='https://api.minecraftservices.com/', name='PROD' [16:18:39] [Render thread/INFO]: Setting user: Player226 [16:18:39] [Render thread/INFO]: Backend library: LWJGL version 3.2.2 SNAPSHOT [16:18:42] [Render thread/WARN]: ERROR : Couldn't load Narrator library : Unable to load library 'fliteWrapper': Can't obtain InputStream for linux-x86-64/libfliteWrapper.so [16:18:42] [Render thread/INFO]: Reloading ResourceManager: Default [16:18:43] [Realms Notification Availability checker #1/INFO]: Could not authorize you against Realms server: Invalid session id /home/johy3943/.local/lib/python3.10/site-packages/minerl/env/../MCP-Reborn/launchClient.sh: line 52: 11400 Killed java -Xmx$maxMem -jar $fatjar --envPort=$port

Minecraft process finished unexpectedly. There was an error with Malmo.

Miffyli commented 7 months ago

Hey, could you include full log of everything, just in case? Double-check that MineRL installation went succesfully. Also, I think sometimes with WSL you might need to use the xvfb-run -a python [script-name] thing to run it correctly (although usually I did not need this).

JoHaYoung227 commented 7 months ago

There was no error when importing minerl, so there seemed to be no problem with the installation. A new error occurred when using the xvfb-run-apython [script-name] command. The overall error statement is as follows. (rlenv) johy3943@johayoung:~/anaconda3/envs/rlenv$ xvfb-run -a python minerl_test.py /home/johy3943/anaconda3/envs/rlenv/lib/python3.7/site-packages/gym/logger.py:34: UserWarning: WARN: Box bound precision lowered by casting to float32 warnings.warn(colorize("%s: %s" % ("WARN", msg % args), "yellow")) Traceback (most recent call last): File "minerl_test.py", line 5, in env = gym.make("MineRLObtainDiamond-v0") # A MineRLObtainDiamond-v0 env File "/home/johy3943/anaconda3/envs/rlenv/lib/python3.7/site-packages/gym/envs/registration.py", line 184, in make return registry.make(id, kwargs) File "/home/johy3943/anaconda3/envs/rlenv/lib/python3.7/site-packages/gym/envs/registration.py", line 106, in make env = spec.make(kwargs) File "/home/johy3943/anaconda3/envs/rlenv/lib/python3.7/site-packages/gym/envs/registration.py", line 76, in make env = cls(**_kwargs) File "/home/johy3943/anaconda3/envs/rlenv/lib/python3.7/site-packages/minerl/env/core.py", line 137, in init self.instance = self._get_new_instance(port) File "/home/johy3943/anaconda3/envs/rlenv/lib/python3.7/site-packages/minerl/env/core.py", line 159, in _get_new_instance instance.launch() File "/home/johy3943/anaconda3/envs/rlenv/lib/python3.7/site-packages/minerl/env/malmo.py", line 513, in launch raise EOFError(error_str + "\n\nMinecraft process finished unexpectedly. There was an error with Malmo.") EOFError: FAILURE: Build failed with an exception.

BUILD FAILED

Total time: 7.229 secs

Minecraft process finished unexpectedly. There was an error with Malmo.


The Python files I tried to run are as follows.

import gym import minerl

Run a random agent through the environment

env = gym.make("MineRLObtainDiamond-v0") # A MineRLObtainDiamond-v0 env

obs = env.reset() done = False

while not done:

Take a no-op through the environment.

obs, rew, done, _ = env.step(env.action_space.noop())
Miffyli commented 7 months ago

@JoHaYoung227 What command did you use to install the MineRL? If you used pip install minerl, this installs v0.4.4 which could potentially be broken by now (not updated). Try the pip install command in the readme of this repo.

JoHaYoung227 commented 7 months ago

Hello, I successfully resolved all errors and installed version 0.3.7 of minerl. However, another error occurred. This happened when I executed the following command.

xvfb-run -a python3 example.py

The error message is as follows:

Traceback (most recent call last):
  File "example.py", line 7, in <module>
    env = gym.make('MineRLNavigateDense-v0')
  File "/home/johy3943/anaconda3/envs/minerl2/lib/python3.6/site-packages/gym/envs/registration.py", line 184, in make
    return registry.make(id, **kwargs)
  File "/home/johy3943/anaconda3/envs/minerl2/lib/python3.6/site-packages/gym/envs/registration.py", line 106, in make
    env = spec.make(**kwargs)
  File "/home/johy3943/anaconda3/envs/minerl2/lib/python3.6/site-packages/gym/envs/registration.py", line 76, in make
    env = cls(**_kwargs)
  File "/home/johy3943/anaconda3/envs/minerl2/lib/python3.6/site-packages/minerl/env/core.py", line 137, in __init__
    self.instance = self._get_new_instance(port)
  File "/home/johy3943/anaconda3/envs/minerl2/lib/python3.6/site-packages/minerl/env/core.py", line 159, in _get_new_instance
    instance.launch()
  File "/home/johy3943/anaconda3/envs/minerl2/lib/python3.6/site-packages/minerl/env/malmo.py", line 502, in launch
    _check_for_launch_errors(line)
  File "/home/johy3943/anaconda3/envs/minerl2/lib/python3.6/site-packages/minerl/env/malmo.py", line 790, in _check_for_launch_errors
    "ERROR! MineRL could not detect an X Server, Monitor, or Virtual Monitor! "
RuntimeError: ERROR! MineRL could not detect an X Server, Monitor, or Virtual Monitor!

In order to run minerl environments WITHOUT A HEAD use a software renderer such as 'xvfb':
                xvfb-run python3 <your_script.py>
        ! NOTE: xvfb conflicts with NVIDIA-drivers!
        ! To run headless MineRL on a system with NVIDIA-drivers, please start a
        ! vnc server of your choosing and then `export DISPLAY=:<insert ur vnc server #>

If you're receiving this error and there is a monitor attached, make sure your current displayvariable is set correctly:

                 DISPLAY=:0 python3 <your_script.py>
        ! NOTE: For this to work your account must be logged on the physical monitor.

If none of these steps work, please complain in the discord!
If all else fails, JUST PUT THIS IN A DOCKER CONTAINER! :)

What could this issue be? I don't use a GPU. Please help. Thank you for your response.

Miffyli commented 7 months ago

@JoHaYoung227 Check the error message; sometimes xvfb-run does not function correctly. Unfortunately the pointers in the error message are the only tips I have for next step. Googling issues of running games in xvfb might result into something as well.

JoHaYoung227 commented 7 months ago

thank you ! I solved it ! :)