1

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'
Thayer
  • 35
  • 3
  • Could you please run the command `pip show python-chess` and show output? – Oleksii Tambovtsev Dec 25 '21 at 19:13
  • @OleksiiTambovtsev `Name: python-chess Version: 0.23.11 Summary: A pure Python chess library with move generation and validation, Polyglot opening book probing, PGN reading and writing, Gaviota tablebase probing, Syzygy tablebase probing and XBoard/UCI engine communication. Home-page: https://github.com/niklasf/python-chess Author: Niklas Fiekas Author-email: niklas.fiekas@backscattering.de License: GPL3 Location: /usr/local/lib/python3.7/dist-packages Requires: Required-by:` – Thayer Dec 25 '21 at 19:29

1 Answers1

1

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 
Oleksii Tambovtsev
  • 2,666
  • 1
  • 3
  • 21