Search code examples
python-3.xsubprocessspyder

can't get Stockfish in Python to work, throws FileNotFoundError


I want to write a chess related program, where I need to evaluate moves. For this purpose, I have installed the python stockfish package from https://github.com/zhelyabuzhsky/stockfish.

But when I test even one line, with

from stockfish import Stockfish

stockfish = Stockfish()

I get the error

Traceback (most recent call last):

  File "<ipython-input-12-fef147213e5f>", line 1, in <module>
    stockfish = Stockfish()

  File "C:\Users\ajdin\Anaconda3\lib\site-packages\stockfish.py", line 27, in __init__
    stdout=subprocess.PIPE

  File "C:\Users\ajdin\Anaconda3\lib\subprocess.py", line 707, in __init__
    restore_signals, start_new_session)

  File "C:\Users\ajdin\Anaconda3\lib\subprocess.py", line 990, in _execute_child
    startupinfo)

FileNotFoundError: [WinError 2] The system cannot find the file specified.

I've also tried the same thing with a similar package from https://github.com/iamjarret/pystockfish with the pystockfish package, but the same error arose. (only now the main code was deep = Engine(depth=20) ).

I've searched online for this error, but couldn't really find a solution. Does anyone know what is wrong, am I missing any files here? Any more required info, I am happy to give.


Solution

  • In both cases my pathfile "stockfish" was incorrect. It needed the full pathname as argument.