I have made a GUI (using PySimpleGUI) where you can play against Stockfish (I used python-chess module). I make an .exe-file using Pyinstaller --noconsole, but when i run it, it opens Stockfish in a console. When I run it form source, in PyCharm, Stockfish runs silently in the background.
The relevant lines of code are (I guess):
engine = chess.engine.SimpleEngine.popen_uci(engine_filename, shell = False)
and, a bit later,
best_move = engine.play(board, chess.engine.Limit(depth=20)).move
Any advice on how I can make Stockfish run silently in the background also form the .exe-file?
Define your engine like below.
import subprocess
engine = chess.engine.SimpleEngine.popen_uci(
engine_filename,
shell = False,
creationflags=subprocess.CREATE_NO_WINDOW)