BurnySc2 / python-sc2

A StarCraft II bot api client library for Python 3
MIT License
510 stars 158 forks source link

AttributeError: 'WarpGateBot' object has no attribute 'structures' #132

Closed gooch12013 closed 2 years ago

gooch12013 commented 2 years ago

I was testing using the "warpgate_push.py," and I got the flowing errors

I did change the map, and that's it.

PS E:\Programing\SC2> python sc2-bot.py C:\Users\DG_Main\AppData\Roaming\Python\Python310\site-packages\sc2\main.py:325: DeprecationWarning: There is no current event loop result = asyncio.get_event_loop().run_until_complete( INFO:sc2.protocol:Client status changed to Status.launched (was None) INFO:sc2.controller:Creating new game INFO:sc2.controller:Map: 2000AtmospheresAIE INFO:sc2.controller:Players: Bot(Race.Protoss, <main.WarpGateBot object at 0x000002A4A74BDDB0>), Computer Easy(Protoss, RandomBuild) INFO:sc2.protocol:Client status changed to Status.init_game (was Status.launched) INFO:sc2.protocol:Client status changed to Status.in_game (was None) INFO:root:Player 1 - Bot(Race.Protoss, <main.WarpGateBot object at 0x000002A4A74BDDB0>) ERROR:sc2.main:AI step threw an error Traceback (most recent call last): File "C:\Users\DG_Main\AppData\Roaming\Python\Python310\site-packages\sc2\main.py", line 150, in _play_game_ai await ai.on_step(iteration) File "E:\Programing\SC2\sc2-bot.py", line 63, in on_step if self.structures(UnitTypeId.PYLON).ready: AttributeError: 'WarpGateBot' object has no attribute 'structures' ERROR:sc2.main:resigning due to previous error INFO:root:Result for player 1 - Bot(Race.Protoss, <main.WarpGateBot object at 0x000002A4A74BDDB0>): Defeat INFO:sc2.protocol:Client status changed to Status.launched (was Status.in_game) INFO:sc2.protocol:Client status changed to Status.quit (was Status.launched) INFO:sc2.sc2process:kill_switch: Process cleanup INFO:sc2.sc2process:Cleaning up... INFO:sc2.sc2process:Cleanup complete PS E:\Programing\SC2>

BurnySc2 commented 2 years ago

I'm guessing you previously did a pip install sc2 which installs https://github.com/Dentosal/python-sc2 If that is the case then in C:\Users\DG_Main\AppData\Roaming\Python\Python310\site-packages\sc2\bot_ai.py you'll be unable to find any entry of self.structures if you search through the file.

In that case you may have to uninstall pip uninstall sc2 burnysc2 and reinstall this library with pip install --force-reinstall burnysc2 This should fix it because dentosal's lib and my fork both use the site-packages subfolder sc2 which allows you to keep the imports the same if you switched from that lib to this fork.

Does that work?

gooch12013 commented 2 years ago

It looks like that was it. I also had to do "pip install six" to get the script to work.

BurnySc2 commented 2 years ago

I also had to do "pip install six" to get the script to work.

I heard this before from someone - looks like I'll have to add it to main dependencies. Thanks!