简体   繁体   English

Errno 8 执行格式错误 - Stockfish/python 国际象棋

[英]Errno 8 Exec Format Error - Stockfish/python chess

I am trying to access Stockfish evaluations through python chess, however, whenever I try to run the code, I am met with "[Errno 8] Exec format error".我正在尝试通过 python 国际象棋访问 Stockfish 评估,但是,每当我尝试运行代码时,都会遇到“[Errno 8] Exec 格式错误”。 I tried running the some code off the documentation and am met with the same error.我尝试从文档中运行一些代码,但遇到了同样的错误。 I read some articles and they talked about adding a shebang to the executable code but I don't see anyone else needing to do this, or any reference of it in the documentation.我读了一些文章,他们谈到在可执行代码中添加一个 shebang,但我没有看到其他人需要这样做,或者在文档中对它的任何引用。 Am I just really dumb?我真的很笨吗? Sorry, I am still new to coding.对不起,我还是编码新手。 The documentation code is below:文档代码如下:

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'

Use a stockfish that is compiled for linux as the machine is not run on windows.使用为 linux 编译的鱼,因为机器不在 windows 上运行。

If you encounter permission issue use the command for example:如果遇到权限问题,请使用以下命令,例如:

chmod 777 "/content/drive.../stockfish_linux"
or
!chmod 777 "/content/drive.../stockfish_linux"
for google colab

where stockfish_linux is your stockfish engine file. stockfish_linux 是您的 stockfish 引擎文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM