Errno 8 Exec 格式错误 - Stockfish/python 国际象棋
Errno 8 Exec Format Error - Stockfish/python chess
我正在尝试通过 python 国际象棋访问 Stockfish 评估,但是,每当我尝试 运行 代码时,我都会遇到“[Errno 8] Exec 格式错误”。我尝试 运行 从文档中删除一些代码,但遇到了同样的错误。我读了一些文章,他们谈到了向可执行代码添加一个 shebang,但我没有看到任何其他人需要这样做,也没有在文档中看到它的任何引用。我真的很笨吗?对不起,我还是编码新手。文档代码如下:
import chess
import chess.engine
engine = chess.engine.SimpleEngine.popen_uci("/content/drive/MyDrive/stockfish_14.1_win_x64_avx2/stockfish_14.1_win_x64_avx2.exe")
board = chess.Board()
info = engine.analyse(board, chess.engine.Limit(time=0.1))
print("Score:", info["score"])
# Score: PovScore(Cp(+20), WHITE)
board = chess.Board("r1bqkbnr/p1pp1ppp/1pn5/4p3/2B1P3/5Q2/PPPP1PPP/RNB1K1NR w KQkq - 2 4")
info = engine.analyse(board, chess.engine.Limit(depth=20))
print("Score:", info["score"])
# Score: PovScore(Mate(+1), WHITE)
engine.quit()
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-9-9affa6765785> in <module>()
2 import chess.engine
3
----> 4 engine = chess.engine.SimpleEngine.popen_uci("/content/drive/MyDrive/stockfish_14.1_win_x64_avx2/stockfish_14.1_win_x64_avx2.exe")
5
6 board = chess.Board()
15 frames
/usr/lib/python3.7/subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, start_new_session)
1549 if errno_num == errno.ENOENT:
1550 err_msg += ': ' + repr(err_filename)
-> 1551 raise child_exception_type(errno_num, err_msg, err_filename)
1552 raise child_exception_type(err_msg)
1553
OSError: [Errno 8] Exec format error: '/content/drive/MyDrive/stockfish_14.1_win_x64_avx2/stockfish_14.1_win_x64_avx2.exe'
使用为 linux 编译的鳕鱼,因为 windows 上的机器不是 运行。
如果遇到权限问题,请使用以下命令:
chmod 777 "/content/drive.../stockfish_linux"
or
!chmod 777 "/content/drive.../stockfish_linux"
for google colab
其中 stockfish_linux 是您的鳕鱼引擎文件。
我正在尝试通过 python 国际象棋访问 Stockfish 评估,但是,每当我尝试 运行 代码时,我都会遇到“[Errno 8] Exec 格式错误”。我尝试 运行 从文档中删除一些代码,但遇到了同样的错误。我读了一些文章,他们谈到了向可执行代码添加一个 shebang,但我没有看到任何其他人需要这样做,也没有在文档中看到它的任何引用。我真的很笨吗?对不起,我还是编码新手。文档代码如下:
import chess
import chess.engine
engine = chess.engine.SimpleEngine.popen_uci("/content/drive/MyDrive/stockfish_14.1_win_x64_avx2/stockfish_14.1_win_x64_avx2.exe")
board = chess.Board()
info = engine.analyse(board, chess.engine.Limit(time=0.1))
print("Score:", info["score"])
# Score: PovScore(Cp(+20), WHITE)
board = chess.Board("r1bqkbnr/p1pp1ppp/1pn5/4p3/2B1P3/5Q2/PPPP1PPP/RNB1K1NR w KQkq - 2 4")
info = engine.analyse(board, chess.engine.Limit(depth=20))
print("Score:", info["score"])
# Score: PovScore(Mate(+1), WHITE)
engine.quit()
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-9-9affa6765785> in <module>()
2 import chess.engine
3
----> 4 engine = chess.engine.SimpleEngine.popen_uci("/content/drive/MyDrive/stockfish_14.1_win_x64_avx2/stockfish_14.1_win_x64_avx2.exe")
5
6 board = chess.Board()
15 frames
/usr/lib/python3.7/subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, start_new_session)
1549 if errno_num == errno.ENOENT:
1550 err_msg += ': ' + repr(err_filename)
-> 1551 raise child_exception_type(errno_num, err_msg, err_filename)
1552 raise child_exception_type(err_msg)
1553
OSError: [Errno 8] Exec format error: '/content/drive/MyDrive/stockfish_14.1_win_x64_avx2/stockfish_14.1_win_x64_avx2.exe'
使用为 linux 编译的鳕鱼,因为 windows 上的机器不是 运行。
如果遇到权限问题,请使用以下命令:
chmod 777 "/content/drive.../stockfish_linux"
or
!chmod 777 "/content/drive.../stockfish_linux"
for google colab
其中 stockfish_linux 是您的鳕鱼引擎文件。