minerl icon indicating copy to clipboard operation
minerl copied to clipboard

TypeError: a bytes-like object is required, not 'NoneType'

Open AromaticHydrocarbon opened this issue 1 year ago • 3 comments

import minerl
import gym
import logging

logging.basicConfig(level=logging.DEBUG)
env = gym.make('MineRLNavigateDense-v0')


obs = env.reset()
done = False
net_reward = 0

while not done:
    action = env.action_space.noop()
    action['camera'] = [0, 0.03*obs["compassAngle"]]
    action['back'] = 0
    action['forward'] = 1
    action['jump'] = 1
    action['attack'] = 1
    obs, reward, done, info = env.step(
        action)
    net_reward += reward
    print("Total reward: ", net_reward)

INFO:minerl.env.malmo.instance.c17c95:Starting Minecraft process: ['D:\Anaconda\envs\minecraftrl\lib\site-packages\minerl\env\..\MCP-Reborn\launchClient.bat', '-port', '12628', '-env', '-runDir', 'D:\Anaconda\envs\minecraftrl\lib\site-packages\minerl\env\..\MCP-Reborn\run'] INFO:process_watcher:Launching process watcher daemonizer. D:\Anaconda\envs\minecraftrl\lib\runpy.py:127: RuntimeWarning: 'minerl.utils.process_watcher' found in sys.modules after import of package 'minerl.utils', but prior to execution of 'minerl.utils.process_watcher'; this may result in unpredictable behaviour warn(RuntimeWarning(msg)) D:\Anaconda\envs\minecraftrl\lib\runpy.py:127: RuntimeWarning: 'daemoniker._daemonize_windows' found in sys.modules after import of package 'daemoniker', but prior to execution of 'daemoniker._daemonize_windows'; this may result in unpredictable behaviour warn(RuntimeWarning(msg)) INFO:process_watcher:Process watcher daemonizer launched successfully. DEBUG:minerl.env.malmo.instance.c17c95:SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". DEBUG:minerl.env.malmo.instance.c17c95:SLF4J: Defaulting to no-operation (NOP) logger implementation DEBUG:minerl.env.malmo.instance.c17c95:SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. DEBUG:minerl.env.malmo.instance.c17c95:[10:06:55] [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' DEBUG:minerl.env.malmo.instance.c17c95:[10:06:58] [Render thread/INFO]: Setting user: Player593 DEBUG:minerl.env.malmo.instance.c17c95:[10:06:59] [Render thread/INFO]: Backend library: LWJGL version 3.2.2 SNAPSHOT ERROR:minerl.env.malmo.instance.c17c95:[10:07:02] [Render thread/WARN]: ERROR : Couldn't load Narrator library : Unable to load library 'SAPIWrapper_x64': Can't obtain InputStream for win32-x86-64/SAPIWrapper_x64.dll ERROR:minerl.env.malmo.instance.c17c95:ERROR : Couldn't load Narrator library : Unable to load library 'SAPIWrapper_x86': Can't obtain InputStream for win32-x86-64/SAPIWrapper_x86.dll DEBUG:minerl.env.malmo.instance.c17c95: DEBUG:minerl.env.malmo.instance.c17c95:[10:07:02] [Render thread/INFO]: Reloading ResourceManager: Default DEBUG:minerl.env.malmo.instance.c17c95:[10:07:03] [Realms Notification Availability checker #1/INFO]: Could not authorize you against Realms server: Invalid session id DEBUG:minerl.env.malmo.instance.c17c95:[10:07:07] [Render thread/INFO]: OpenAL initialized. DEBUG:minerl.env.malmo.instance.c17c95:[10:07:07] [Render thread/INFO]: Sound engine started DEBUG:minerl.env.malmo.instance.c17c95:[10:07:08] [Render thread/INFO]: Created: 1024x1024x4 minecraft:textures/atlas/blocks.png-atlas DEBUG:minerl.env.malmo.instance.c17c95:[10:07:08] [Render thread/INFO]: Created: 256x128x4 minecraft:textures/atlas/signs.png-atlas DEBUG:minerl.env.malmo.instance.c17c95:[10:07:08] [Render thread/INFO]: Created: 1024x512x4 minecraft:textures/atlas/banner_patterns.png-atlas DEBUG:minerl.env.malmo.instance.c17c95:[10:07:08] [Render thread/INFO]: Created: 1024x512x4 minecraft:textures/atlas/shield_patterns.png-atlas DEBUG:minerl.env.malmo.instance.c17c95:[10:07:08] [Render thread/INFO]: Created: 256x256x4 minecraft:textures/atlas/chest.png-atlas DEBUG:minerl.env.malmo.instance.c17c95:[10:07:08] [Render thread/INFO]: Created: 512x256x4 minecraft:textures/atlas/beds.png-atlas DEBUG:minerl.env.malmo.instance.c17c95:[10:07:08] [Render thread/INFO]: Created: 512x256x4 minecraft:textures/atlas/shulker_boxes.png-atlas DEBUG:minerl.env.malmo.instance.c17c95:[10:07:09] [Render thread/INFO]: Created: 256x256x0 minecraft:textures/atlas/particles.png-atlas DEBUG:minerl.env.malmo.instance.c17c95:[10:07:09] [Render thread/INFO]: Created: 256x256x0 minecraft:textures/atlas/paintings.png-atlas DEBUG:minerl.env.malmo.instance.c17c95:[10:07:09] [Render thread/INFO]: Created: 256x128x0 minecraft:textures/atlas/mob_effects.png-atlas DEBUG:minerl.env.malmo.instance.c17c95:[10:07:10] [Thread-5/INFO]: [STDOUT]: ***** Start MalmoEnvServer on port 12628 DEBUG:minerl.env.malmo.instance.c17c95:[10:07:10] [Thread-5/INFO]: [STDOUT]: CLIENT enter state: DORMANT INFO:minerl.env.malmo.instance.c17c95:Minecraft process ready DEBUG:minerl.env._multiagent:Creating socket connection Malmo[None:c17c95, proc=3736, addr=localhost:12628, locked=True] INFO:minerl.env.malmo:Logging output of Minecraft to .\logs\mc_3628.log DEBUG:minerl.env.malmo.instance.c17c95:[10:07:10] [Thread-5/INFO]: [STDOUT]: SERVER enter state: DORMANT DEBUG:minerl.env._multiagent:Saying hello for client: Malmo[None:c17c95, proc=3736, addr=localhost:12628, locked=True] INFO:minerl.env._multiagent:Attempting to quit: Malmo[None:c17c95, proc=3736, addr=localhost:12628, locked=True] DEBUG:minerl.env._multiagent:Sending mission init: Malmo[None:c17c95, proc=3736, addr=localhost:12628, locked=True] DEBUG:minerl.env.malmo.instance.c17c95:[10:07:10] [EnvServerSocketHandler/INFO]: Received Mission token ff4c4d38-9a85-4bf2-a1f0-c98390d2264c:0:0:1:true DEBUG:minerl.env.malmo.instance.c17c95:[10:07:10] [EnvServerSocketHandler/INFO]: Received mission init command <MissionInit xmlns="http://ProjectMalmo.microsoft.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SchemaVersion="" PlatformVersion="0.37.0"><Mission><About><Summary>MineRLNavigateDense-v0</Summary></About><ModSettings><MsPerTick>50</MsPerTick></ModSettings><ServerSection><ServerInitialConditions><Time><StartTime>6000</StartTime><AllowPassageOfTime>false</AllowPassageOfTime></Time><Weather>clear</Weather><AllowSpawning>false</AllowSpawning></ServerInitialConditions><ServerHandlers><DefaultWorldGenerator forceReset="true" generatorOptions="{}"/><NavigationDecorator><randomPlacementProperties><maxRandomizedRadius>64</maxRandomizedRadius><minRandomizedRadius>64</minRandomizedRadius><maxRadius>8</maxRadius><minRadius>0</minRadius>diamond_blocksurface</randomPlacementProperties><minRandomizedDistance>0</minRandomizedDistance><maxRandomizedDistance>8</maxRandomizedDistance><randomizeCompassLocation>true</randomizeCompassLocation></NavigationDecorator><ServerQuitFromTimeUp timeLimitMs="300000" description="out_of_time"/><ServerQuitWhenAnyAgentFinishes/></ServerHandlers></ServerSection><AgentSection mode="Survival"><Name>MineRLAgent0</Name><AgentStart><Inventory><InventoryObject slot="0" type="compass" quantity="1"/></Inventory></AgentStart><AgentHandlers><FileBasedPerformanceProducer/><PauseCommand/><VideoProducer want_depth="false"><Width>64</Width><Height>64</Height></VideoProducer><ObservationFromCompass/><ObservationFromFullInventory flat="false"/><HumanLevelCommands/><CameraCommands/><PlaceCommands/><RewardForTouchingBlockType><Block reward="100.0" type="diamond_block" behaviour="onceOnly"/></RewardForTouchingBlockType><RewardForDistanceTraveledToCompassTarget rewardPerBlock="1.0" density="PER_TICK"/><AgentQuitFromTouchingBlockType><Block type="diamond_block"/></AgentQuitFromTouchingBlockType></AgentHandlers></AgentSection></Mission><ExperimentUID>ff4c4d38-9a85-4bf2-a1f0-c98390d2264c</ExperimentUID><ClientRole>0</ClientRole><ClientAgentConnection><ClientIPAddress>127.0.0.1</ClientIPAddress><ClientMissionControlPort>0</ClientMissionControlPort><ClientCommandsPort>0</ClientCommandsPort><AgentIPAddress>127.0.0.1</AgentIPAddress><AgentMissionControlPort>0</AgentMissionControlPort><AgentVideoPort>0</AgentVideoPort><AgentDepthPort>0</AgentDepthPort><AgentLuminancePort>0</AgentLuminancePort><AgentObservationsPort>0</AgentObservationsPort><AgentRewardsPort>0</AgentRewardsPort><AgentColourMapPort>0</AgentColourMapPort></ClientAgentConnection></MissionInit> DEBUG:minerl.env.malmo.instance.c17c95:[10:07:11] [Render thread/INFO]: [STDOUT]: *** creating fake mouse cursor *** ERROR:minerl.env.malmo.instance.c17c95:[10:07:12] [EnvServerSocketHandler/ERROR]: Error while processing commands ERROR:minerl.env.malmo.instance.c17c95:java.lang.NullPointerException: null DEBUG:minerl.env.malmo.instance.c17c95: at com.minerl.multiagent.env.EnvServer.setGameSetttings(EnvServer.java:338) ~[mcprec-6.13.jar:?] DEBUG:minerl.env.malmo.instance.c17c95: at com.minerl.multiagent.env.EnvServer.initMission(EnvServer.java:260) ~[mcprec-6.13.jar:?] DEBUG:minerl.env.malmo.instance.c17c95: at com.minerl.multiagent.env.EnvServer$1.run(EnvServer.java:131) [mcprec-6.13.jar:?] Traceback (most recent call last): File "D:/xt/zj/seminar/minecraftrl/main.py", line 8, in obs = env.reset() File "D:\Anaconda\envs\minecraftrl\lib\site-packages\gym\wrappers\time_limit.py", line 27, in reset return self.env.reset(**kwargs) File "D:\Anaconda\envs\minecraftrl\lib\site-packages\minerl\env_singleagent.py", line 22, in reset multi_obs = super().reset() File "D:\Anaconda\envs\minecraftrl\lib\site-packages\minerl\env_multiagent.py", line 446, in reset self._send_mission(self.instances[0], agent_xmls[0], self._get_token(0, ep_uid)) # Master File "D:\Anaconda\envs\minecraftrl\lib\site-packages\minerl\env_multiagent.py", line 606, in _send_mission ok, = struct.unpack("!I", reply) TypeError: a bytes-like object is required, not 'NoneType' DEBUG:minerl.env.malmo.instance.c17c95:[10:07:13] [Render thread/INFO]: Stopping!

AromaticHydrocarbon avatar Jun 20 '23 02:06 AromaticHydrocarbon

Make sure MineRL installed correctly when you were installing it, and make sure you have only Java 8 and JDK 8 installed.

Miffyli avatar Jun 20 '23 18:06 Miffyli

@AromaticHydrocarbon I am encountering the exact same issue, just wondering have you resolved this one? many thanks.

CooLeee avatar Feb 16 '24 19:02 CooLeee

Changing the version of the JDK to JDK 8 on my Ubuntu system solved the issue. Use the command to quickly alternate the JDK.

sudo update-alternatives --config java

AkagawaTsurunaki avatar Aug 15 '24 05:08 AkagawaTsurunaki