I’m trying to use the python-chess library to interface with Stockfish on macOS, but I’m encountering a TimeoutError during the initialization process. Here’s a simplified version of my code:
import chess.engine
# Set your Stockfish path here
engine_path = '/Applications/Stockfish.app/Contents/MacOS/Stockfish'
if __name__ == '__main__':
engine = chess.engine.SimpleEngine.popen_uci(engine_path)
When I run this script, I get the following error:
<UciProtocol (pid=20778)>: stderr >> 2024-08-10 11:19:05.137 Stockfish[20778:931410] WARNING: Secure coding is automatically enabled for restorable state! However, not on all supported macOS versions of this application. Opt-in to secure coding explicitly by implementing NSApplicationDelegate.applicationSupportsSecureRestorableState:.
<UciProtocol (pid=20778)>: stderr >> 2024-08-10 11:19:05.139 Stockfish[20778:931410] Started app
/Users/username/.venv/lib/python3.9/site-packages/chess/engine.py:154: RuntimeWarning: A loop is being detached from a child watcher with pending handlers
warnings.warn("A loop is being detached from a child watcher with pending handlers", RuntimeWarning)
asyncio.exceptions.TimeoutError
I’ve tried the following to troubleshoot the issue:
- Verified the Stockfish path is correct.
- Increased the timeout value for popen_uci.
- Updated the python-chess library.
- Ensured that my macOS and Python versions are up to date.
Despite these efforts, the error persists. The asyncio.exceptions.TimeoutError suggests that the script is timing out while waiting for Stockfish to initialize.
Has anyone experienced a similar issue on macOS? Are there any specific configurations or additional steps I should take to resolve this?
Edit: I’m using version 1.10.0 of the Python chess library and version 3.9 of Python.