py-stockfish / stockfish

Integrates the Stockfish chess engine with Python (Official fork)
https://py-stockfish.github.io/stockfish/
MIT License
30 stars 9 forks source link

IndexError on MacOS (MacBook M2) [BUG] #48

Closed nIKiTaaaaaaa-coder closed 1 year ago

nIKiTaaaaaaa-coder commented 1 year ago

Traceback (most recent call last): File "/Users/nsegrenev/Documents/Python Projects/console_ches.py", line 305, in stockfish = Stockfish(path="/Applications/Stockfish.app/Contents/MacOS/stockfish-x86-64-vnni256") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/stockfish/models.py", line 58, in init self._read_line().split(" ")[1].split(".")[0].replace("-", "")


IndexError: list index out of range

How do I fix this?
kieferro commented 1 year ago

This is a bug concerning the version parsing and something similar has already been reported in #11 and fixed in #25. Since we now use different methods to detect the version I suspect that this problem has already been fixed. But I would still be interested in how this problem occurs. Could you paste the output of the engine at startup (via command line) and the response after you use the uci command?

nIKiTaaaaaaa-coder commented 1 year ago
nsegrenev@192 ~ % stockfish                                              
Stockfish 15.1 by the Stockfish developers (see AUTHORS file)
nIKiTaaaaaaa-coder commented 1 year ago

or should I run the binary of the stockfish app?

nsegrenev@192 MacOS % ./Stockfish
2023-06-30 09:47:15.737 Stockfish[10787:382138] Warning: Column selection is not supported in view-based table and outline views (<NSTableView: 0x121822e00>).
2023-06-30 09:47:15.759 Stockfish[10787:382138] Launching engine with path /Applications/Stockfish.app/Contents/MacOS/stockfish-arm64
2023-06-30 09:47:15.782 Stockfish[10787:382138] Started app
nIKiTaaaaaaa-coder commented 1 year ago
nsegrenev@192 MacOS % uci
zsh: command not found: uci

Should I install sci via homebrew?

kieferro commented 1 year ago

or should I run the binary of the stockfish app?

nsegrenev@192 MacOS % ./Stockfish
2023-06-30 09:47:15.737 Stockfish[10787:382138] Warning: Column selection is not supported in view-based table and outline views (<NSTableView: 0x121822e00>).
2023-06-30 09:47:15.759 Stockfish[10787:382138] Launching engine with path /Applications/Stockfish.app/Contents/MacOS/stockfish-arm64
2023-06-30 09:47:15.782 Stockfish[10787:382138] Started app

Was that the version you were using? That would explain it, because the parser then tries to read the version number from the warning message, which of course can't work.

Should I install sci via homebrew?

I'm sorry if that wasn't clear: The uci command is for chess engines, not for the command line. So you would have to start the engine from the command line and just input uci to get some basic information about the engine.

johndoknjas commented 1 year ago

@nIKiTaaaaaaa-coder Building on what kieferro said, if you could do something like the following that would be good: image Here I'm running Linux, but it should be similar on Mac. The 'stockfish-engine' is just the name of the stockfish executable I'm using myself. Once it loads, typing uci will get stockfish to output all that information. If the first line doesn't follow a similar format to what I got ("id name Stockfish 140722"), then it could be a format our library hasn't anticipated yet.

Also, the version of the Python Stockfish library on PyPI was last updated in July 2022. The code in this repo is the updated version, but unfortunately we haven't been able to upload it on PyPI yet. You could try making a new models.py file in your project directory, copying the code into it, and then in your main file, doing from models import Stockfish instead of from stockfish import Stockfish. If things then run fine for you, this was likely a bug we patched within the last year.

nIKiTaaaaaaa-coder commented 1 year ago

I am sorry, I just set the incorrect path for the engine, I had to choose the path from homebrew, not from the app.