cocacola-lab / MineLand

Simulating Large-Scale Multi-Agent Interactions with Limited Multimodal Senses and Physical Needs
MIT License
54 stars 9 forks source link

File "", line 322, in decode UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc1 in position 221: invalid start byte #16

Closed Raven-July closed 1 month ago

Raven-July commented 3 months ago

I only encountered this problem on windows10 when starting the server(Docker is fine) I managed to solved this. first, the output is as followed:

[Tasks] task mode has been modified as cooperative [Tasks] Agent(s) need to survive for 0.01 days (240.0 ticks) [MineLand] MineLand Simulator is initializing... [MineLand] Starting server... [Server] Start to listen outputs. [Server] Starting net.fabricmc.loader.impl.game.minecraft.BundlerClassPathCapture Exception in thread Thread-1 (listen_outputs): Traceback (most recent call last): File "D:\NEWNEWNEW\python3.11\Lib\threading.py", line 1045, in _bootstrap_inner self.run() File "D:\NEWNEWNEW\python3.11\Lib\threading.py", line 982, in run self._target(*self._args, **self._kwargs) File "E:\Python_Projects\MineLand\mineland\sim\server_manager.py", line 129, in listen_outputs output = self.process.stdout.readline() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 322, in decode UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc1 in position 221: invalid start byte

I fixed by changing the "subprocess.Popen" function in server-manager.py

1: LINE 95: CHANGE self.process = subprocess.Popen(args, cwd=self.path, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, text=True) TO self.process = subprocess.Popen(args, cwd=self.path, shell=False, stdout=subprocess.PIPE,stderr=subprocess.PIPE, stdin=subprocess.PIPE)

2: LINE 129: CHANGE output = self.process.stdout.readline() TO output_bytes = self.process.stdout.readline() output = output_bytes.decode('utf-8', errors='ignore')

After the change everything goes well. But after all I chose to ignore the decode problem which didn't appear in my docker environment Don't know whether this could bring unforeseen cosequenses

YXHXianYu commented 3 months ago

Thanks for your feedback, I'll check it later!