on win 7 i can communicate with a chess engine via commandline. Small Example Session with Stockfish on Win 7:
C:\\run\\Stockfish>stockfish-x64.exe
Stockfi
You might want to use asyncio like python-chess does. See
engine.py
and the example from the documentation
import asyncio
import chess
import chess.engine
async def main():
transport, engine = await chess.engine.popen_uci("/usr/bin/stockfish")
board = chess.Board()
while not board.is_game_over():
result = await engine.play(board, chess.engine.Limit(time=0.1))
board.push(result.move)
await engine.quit()
asyncio.set_event_loop_policy(chess.engine.EventLoopPolicy())
asyncio.run(main())
You've got a deadlock: the subprocess is waiting for input, while your program is waiting for it to output more lines in
for line in engine.stdout:
print(line.strip())
This loop only stops when the subprocess closes its stdout
.