AttributeError: 'Stockfish' object has no attribute 'stockfish'

1.8k Views Asked by At

I am writing a lichess bot with Stockfish. The first line of code fails with multiple error messages:

Exception ignored in: <function Stockfish.__del__ at 0x000002501F877550>
Traceback (most recent call last):
  File "C:\Users\jcbri\AppData\Local\Programs\Python\Python39\lib\site-packages\stockfish\models.py", line 396, in __del__    self._put("quit")
  File "C:\Users\jcbri\AppData\Local\Programs\Python\Python39\lib\site-packages\stockfish\models.py", line 80, in _put    
    if not self.stockfish.stdin:
AttributeError: 'Stockfish' object has no attribute 'stockfish'

The bot says this in console:

2021-08-06 16:05:04,694: Backing off play_game(...) for 2.0s (FileNotFoundError: [WinError 2] The system cannot find the file specified)

My code:

from stockfish import Stockfish
fish = Stockfish("C:/Users/jcbri/Downloads/stockfish_14_win_x64_avx2/stockfish_14_win_x64_avx2/stockfish_14_win_x64_avx2.exe")

## My evaluation code

I am using Windows 10 and have the Stockfish module installed. Is there some file or snippet of code I'm missing?

1

There are 1 best solutions below

0
On

Try using "\" instead of "/"

from stockfish import Stockfish
fish = Stockfish("C:\\Users\\jcbri\\Downloads\\stockfish_14_win_x64_avx2\\tockfish_14_win_x64_avx2\\stockfish_14_win_x64_avx2.exe")