Starcraft II not launching
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'
(x86)/StarCraft II/Versions/Base86383/SC2_x64.exe maybe not able to execute 64 bit ?
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:
- Find the id of sc2.
$ lutris --list-games
- Create a bash script to run sc2.
$ lutris lutris:rungameid/1 --output-script sc2.bash
You will find that this script sc2.bash can run sc2 as if launched from the lutris gui. It creates several environment variables that tell wine how to run sc2. The way I think about this is that wine behaves as a Windows XP computer by default but if you configure it right it can look to sc2 like a Windows 10. The variables in my computer running Ubuntu 20.04 look like:
DISABLE_LAYER_AMD_SWITCHABLE_GRAPHICS_1="1"
SDL_VIDEO_FULLSCREEN_DISPLAY="off"
DRI_PRIME="1"
LD_LIBRARY_PATH="/home/aneesh/.local/share/lutris/runners/wine/lutris-5.0-x86_64/lib:/home/aneesh/.local/share/lutris/runners/wine/lutris-5.0-x86_64/lib64:/lib/x86_64-linux-gnu:/lib/i386-linux-gnu:/lib:/lib32:/lib/i386-linux-gnu/i686/sse2:/lib/i386-linux-gnu/sse2:/usr/lib/x86_64-linux-gnu/libfakeroot:/lib64:/lib64:/usr/lib:/usr/lib64:/usr/lib32:/usr/lib64:/usr/lib/i386-linux-gnu:/usr/lib/x86_64-linux-gnu:/home/aneesh/.local/share/lutris/runtime/Ubuntu-18.04-i686:/home/aneesh/.local/share/lutris/runtime/steam/i386/lib/i386-linux-gnu:/home/aneesh/.local/share/lutris/runtime/steam/i386/lib:/home/aneesh/.local/share/lutris/runtime/steam/i386/usr/lib/i386-linux-gnu:/home/aneesh/.local/share/lutris/runtime/steam/i386/usr/lib:/home/aneesh/.local/share/lutris/runtime/Ubuntu-18.04-x86_64:/home/aneesh/.local/share/lutris/runtime/steam/amd64/lib/x86_64-linux-gnu:/home/aneesh/.local/share/lutris/runtime/steam/amd64/lib:/home/aneesh/.local/share/lutris/runtime/steam/amd64/usr/lib/x86_64-linux-gnu:/home/aneesh/.local/share/lutris/runtime/steam/amd64/usr/lib:$LD_LIBRARY_PATH"
DXVK_CONFIG_FILE="/home/aneesh/Games/battlenet/dxvk.conf"
DXVK_STATE_CACHE_PATH="/home/aneesh/Games/battlenet"
STAGING_SHARED_MEMORY="1"
__GL_SHADER_DISK_CACHE="1"
__GL_SHADER_DISK_CACHE_PATH="/home/aneesh/Games/battlenet"
WINEDEBUG="-all"
WINEARCH="win64"
WINEPREFIX="/home/aneesh/Games/battlenet"
WINEESYNC="1"
WINEFSYNC="0"
DXVK_NVAPIHACK="0"
WINEDLLOVERRIDES="api-ms-win-crt-private-l1-1-0,ucrtbase=n,b;d3d12,nvapi,nvapi64,winemenubuilder="
WINE_LARGE_ADDRESS_AWARE="1"
TERM="xterm"
So what I did is create a .env file with all these key-value pairs which are run automagically by vscode when you run an AI script. If running the script manually this also works:
$ set -a ; source .env ; set +a
$ python worker_rush.py
As I said earlier. This is probably not your exact problem but It seems that in your case python-sc2 is trying to run a different version/configuration of wine than lutris does. Hope this helps.
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.
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.