Python-chess: 模块 'chess.engine' 没有属性 'SimpleEngine'

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

这是一个更大项目的一部分,但我创建了一个新文件来解决这个问题。对不起,我还是编码新手。目前,我正在尝试对国际象棋中的位置进行鳕鱼评估,但是每当我尝试 运行 代码时,我都会得到“AttributeError: module 'chess.engine' has no attribute 'SimpleEngine'” 我看过在互联网上找不到任何东西,我是不是很笨?我也尝试了文档中的代码,但仍然出现相同的错误。这是文档中的代码:

!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'

我想您使用的是 python-chess 软件包的过时版本。您当前的版本是 0.23.11 而最新版本是 1.999.

您应该尝试升级您的软件包:

pip install python-chess --upgrade