Home > Net >  Python-chess: module 'chess.engine' has no attribute 'SimpleEngine'
Python-chess: module 'chess.engine' has no attribute 'SimpleEngine'

Time:12-26

This is part of a larger project, but I created a new file to solve this one problem. Sorry, I am still new to coding. Currently, I am trying to get stockfish evaluations for positions in Chess, however whenever I try to run the code, I get "AttributeError: module 'chess.engine' has no attribute 'SimpleEngine'" I have looked over the internet and can't find anything, am I being dumb? I tried the code from the documentation as well, and I still get the same error. This is the code from the documentation:

!pip install python-chess
!pip install stockfish
import chess
import chess.engine
from stockfish import Stockfish
import asyncio

engine = chess.engine.SimpleEngine.popen_uci("stockfish")

board = chess.Board()
while not board.is_game_over():
    result = engine.play(board, chess.engine.Limit(time=0.100))
    board.push(result.move)

engine.quit()

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-36-5ab68cc48dde> in <module>()
      4 import asyncio
      5 
----> 6 engine = chess.engine.SimpleEngine.popen_uci("stockfish")
      7 
      8 board = chess.Board()

AttributeError: module 'chess.engine' has no attribute 'SimpleEngine'

CodePudding user response:

I suppose you use an outdated version of the python-chess package. Your current version is 0.23.11 while the latest version is 1.999.

You should try to upgrade your package:

pip install python-chess --upgrade 
  • Related