Skip to content

Race.NoRace KeyError from running ./example/watch_replay.py #226

Description

@JonathanNiehenke

Running the example/watch_replay.py -- Causes KeyError: <Race.NoRace: 0> from .\sc2\bot_ai_internal.py line 754

python .\watch_replay.py

2025-09-23 19:53:09.714 | INFO | sc2.protocol:_execute:75 - Client status changed to Status.in_replay (was None)
2025-09-23 19:53:09.775 | INFO | sc2.protocol:_execute:75 - Client status changed to Status.in_replay (was None)
2025-09-23 19:53:10.023 | INFO | sc2.sc2process:_close_connection:245 - Closing connection at 56194...
2025-09-23 19:53:10.024 | INFO | sc2.sc2process:kill_all:39 - kill_switch: Process cleanup for 1 processes
Traceback (most recent call last):
File "H:\Source\Language\Python\GWiggins\python-sc2\examples\watch_replay.py", line 43, in
run_replay(my_observer_ai, replay_path=str(replay_path))
File "D:\Python39\lib\site-packages\sc2\main.py", line 498, in run_replay
result = asyncio.get_event_loop().run_until_complete(
File "D:\Python39\lib\asyncio\base_events.py", line 642, in run_until_complete
return future.result()
File "D:\Python39\lib\site-packages\sc2\main.py", line 448, in _host_replay
result = await _play_replay(client, ai, realtime)
File "D:\Python39\lib\site-packages\sc2\main.py", line 247, in _play_replay
ai._prepare_step(gs, proto_game_info)
File "D:\Python39\lib\site-packages\sc2\bot_ai_internal.py", line 667, in _prepare_step
self._prepare_units()
File "D:\Python39\lib\site-packages\sc2\bot_ai_internal.py", line 754, in _prepare_units
if unit_id in race_townhalls[self.race]:
KeyError: <Race.NoRace: 0>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions