首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Errno 8 Exec格式错误- Stockfish/python象棋

Errno 8 Exec格式错误- Stockfish/python象棋
EN

Stack Overflow用户
提问于 2021-12-26 00:30:18
回答 1查看 368关注 0票数 0

我试图通过python象棋访问Stockfish评估,但是,每当我试图运行代码时,都会遇到"Errno 8 Exec格式错误“。我试着从文档中运行一些代码,但遇到了同样的错误。我读了一些文章,他们谈到要在可执行代码中添加一个shebang,但是我没有看到任何其他需要这样做的人,也没有在文档中提到它的任何参考。我真的很傻吗?对不起,我对编码还不熟悉。文件代码如下:

代码语言:javascript
复制
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'
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-12-26 01:43:33

使用为linux编译的库存鱼,因为机器不在windows上运行。

如果遇到权限问题,请使用该命令,例如:

代码语言:javascript
复制
chmod 777 "/content/drive.../stockfish_linux"
or
!chmod 777 "/content/drive.../stockfish_linux"
for google colab

其中stockfish_linux是您的股票鱼引擎文件。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70483577

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档