BurnySc2 / python-sc2

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

Starcraft II not launching #124

Open Cheeseboy8020 opened 2 years ago

Cheeseboy8020 commented 2 years ago

I installed starcraft via lutris. Running it with the battle.net launcher works fine. When I try to run the sample i get this error:

<frozen importlib._bootstrap>:914: ImportWarning: _SixMetaPathImporter.find_spec() not found; falling back to find_module()
2022-03-06 15:19:47.234 | INFO     | sc2.sc2process:_close_connection:227 - Closing connection at 17001...
2022-03-06 15:19:47.234 | INFO     | sc2.sc2process:_clean:236 - Cleaning up...
2022-03-06 15:19:47.234 | INFO     | sc2.sc2process:_clean:269 - Cleanup complete
/home/aneesh/miniconda3/envs/StarCraft/lib/python3.10/site-packages/sc2/main.py:608: DeprecationWarning: There is no current event loop
  result = asyncio.get_event_loop().run_until_complete(_host_game(map_settings, players, **kwargs))
Traceback (most recent call last):
  File "/home/aneesh/Documents/ML/Reinforcement/StarCraft/Main.py", line 13, in <module>
    run_game(maps.get("BlackburnAIE"), [
  File "/home/aneesh/miniconda3/envs/StarCraft/lib/python3.10/site-packages/sc2/main.py", line 608, in run_game
    result = asyncio.get_event_loop().run_until_complete(_host_game(map_settings, players, **kwargs))
  File "/home/aneesh/miniconda3/envs/StarCraft/lib/python3.10/asyncio/base_events.py", line 641, in run_until_complete
    return future.result()
  File "/home/aneesh/miniconda3/envs/StarCraft/lib/python3.10/site-packages/sc2/main.py", line 473, in _host_game
    async with SC2Process(
  File "/home/aneesh/miniconda3/envs/StarCraft/lib/python3.10/site-packages/sc2/sc2process.py", line 104, in __aenter__
    self._process = self._launch()
  File "/home/aneesh/miniconda3/envs/StarCraft/lib/python3.10/site-packages/sc2/sc2process.py", line 192, in _launch
    return subprocess.Popen(
  File "/home/aneesh/miniconda3/envs/StarCraft/lib/python3.10/subprocess.py", line 966, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/home/aneesh/miniconda3/envs/StarCraft/lib/python3.10/subprocess.py", line 1842, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: '/home/aneesh/Games/starcraft-ii/drive_c/Program Files (x86)/StarCraft II/Versions/Base86383/SC2_x64.exe'
Excess1972 commented 2 years ago

(x86)/StarCraft II/Versions/Base86383/SC2_x64.exe maybe not able to execute 64 bit ?

diegorodriguezv commented 2 years ago

I didn't have this exact problem but after tinkering a little I've found that lutris does a lot of the heavy lifting of configuring wine for running starcraft 2. I believe that python-sc2 only knows about the environment variables mentioned in the "wine and lutris" section of README.md file.

SC2PF=WineLinux
WINE="/home/aneesh/.local/share/lutris/runners/wine/lutris-5.0-x86_64/bin/wine"
SC2PATH="/home/aneesh/Games/battlenet/drive_c/Program Files (x86)/StarCraft II/"

But wine needs a lot more information to work for sc2. You can see for yourself by typing these commands in a terminal:

Nickrader commented 2 years ago

Edit: I think Diego nailed it. Probably an environment issue. (i.e. $WINE)

What did you type in the command line? Is there a link to the 'sample'? How do you launch Starcraft when it works, from command line (what command) or from GUI?

In the terminal you can echo $ENVIRONMENT_VARIABLE e.g. echo $WINE to see what your terminal has in that session and compare that to https://github.com/BurnySc2/python-sc2#wine-and-lutris

I don't have Lutris, but can get an Exec format error if I try to run it as a script, not wine.

~/.wine/drive_c/Program Files (x86)/StarCraft II$ ./StarCraft\ II.exe bash: ./StarCraft II.exe: cannot execute binary file: Exec format error

whereas ~/.wine/drive_c/Program Files (x86)/StarCraft II$ wine StarCraft\ II.exe launches battlenet without error.

Closest I could come to reproducing the error message.

Nickrader commented 4 months ago

Ubunutu 23.10, Starcraft II via Lutris

So this error comes from being out of environment (that installed burnysc2), and then manually trying to fix dependencies, with '$ pip install sc2'. Which will download the wrong module.

Creating and activating virtual environment python3 -m venv /path/to/virtual_environment/, source /virtual_environment/bin/activate before $ pip install --upgrade burnysc2, seemed to fix it and put an sc2 folder into
/home/username/my_virtual_environment/lib/python3.11/site-packages/

But I get a warning if I'm not in virtual environment when I try to install burnysc2, so I must have been out of/in different virtual environment than when I installed burnysc2, causing me to pip install sc2 to attempt to run the worker_rush.py.