Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sc2reader could not load my replay file

Tags:

python

file

load

I'm new in sc2reader. I tried to load a replay, but I received the following error. Also, I tried different replay files that SC2 could play them. My code is as follow:

from sc2reader.factories import SC2Factory

path = 'D:/Code/Test/replays/LerilakCrest.SC2Replay'
sc2 = SC2Factory()
replay = sc2.load_replay(path)

print('done')

The error message:

Traceback (most recent call last):
File "D:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.5.4\helpers\pydev\pydevd.py", line 2358, in <module>
globals = debugger.run(setup['file'], None, None, is_module)
File "D:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.5.4\helpers\pydev\pydevd.py", line 1778, in run
pydev_imports.execfile(file, globals, locals)  # execute the script
File "D:/Code/Test/read.py", line 9, in <module>
replay = sc2.load_replay(path)
File "D:\Program Files (x86)\Python 2.7\lib\site-packages\sc2reader\factories\sc2factory.py", line 85, in load_replay
return self.load(Replay, source, options, **new_options)
File "D:\Program Files (x86)\Python 2.7\lib\site-packages\sc2reader\factories\sc2factory.py", line 137, in load
return self._load(cls, resource, filename=filename, options=options)
File "D:\Program Files (x86)\Python 2.7\lib\site-packages\sc2reader\factories\sc2factory.py", line 146, in _load
obj = cls(resource, filename=filename, factory=self, **options)
File "D:\Program Files (x86)\Python 2.7\lib\site-packages\sc2reader\resources.py", line 262, in __init__
self._read_data(data_file, self._get_reader(data_file))
File "D:\Program Files (x86)\Python 2.7\lib\site-packages\sc2reader\resources.py", line 592, in _read_data
self.raw_data[data_file] = reader(data, self)
File "D:\Program Files (x86)\Python 2.7\lib\site-packages\sc2reader\readers.py", line 33, in __call__
) for i in range(data.read_bits(5))],
File "D:\Program Files (x86)\Python 2.7\lib\site-packages\sc2reader\decoders.py", line 252, in read_aligned_string
return self._buffer.read_string(count, encoding)
File "D:\Program Files (x86)\Python 2.7\lib\site-packages\sc2reader\decoders.py", line 108, in read_string
return self.read_bytes(count).decode(encoding)
File "D:\Program Files (x86)\Python 2.7\lib\encodings\utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)

UnicodeDecodeError: 'utf8' codec can't decode byte 0xff in position 0: invalid start byte

like image 521
YNR Avatar asked Nov 26 '25 21:11

YNR


1 Answers

Joy, an other user of sc2reader!

I know that problem, it's due to the fact than your version of sc2reader is older than your replay. Personnaly, I've resolved my problem by doing :

sudo pip install git+https://github.com/StoicLoofah/sc2reader@lotv#egg=sc2reader --upgrade

That's the most recent version of sc2reader actually and it supports LotV.

like image 114
DasFranck Avatar answered Nov 29 '25 10:11

DasFranck



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!