1

我想在我的 colab 笔记本中使用 stockfish。我首先尝试了该chess.engine.SimpleEngine.popen_uci()命令,该命令似乎已过时,因为module 'chess.engine' has no attribute 'SimpleEngine'

所以我尝试了鱼本身:

from stockfish import Stockfish

stockfish = Stockfish('/usr/local/lib/python3.7/dist-packages/stockfish')

在这里我总是得到错误:

权限被拒绝:'/usr/local/lib/python3.7/dist-packages/stockfish'

我用谷歌搜索它并想出了一些好的尝试:

我尝试使用!chmod +x '/usr/local/lib/python3.7/dist-packages/stockfish'which 编译,但没有解决问题,并且!chmod +x 'stockfish', 没有找到文件夹。

那么我究竟如何授予使用stockfish文件夹的权限呢?

4

1 回答 1

0

您需要将os.setuid设置为 0,如下面的代码:

! wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.9.2-linux-x86_64.tar.gz -q
! tar -xzf elasticsearch-7.9.2-linux-x86_64.tar.gz
! chown -R daemon:daemon elasticsearch-7.9.2

import os
from subprocess import Popen, PIPE, STDOUT
es_server = Popen(['elasticsearch-7.9.2/bin/elasticsearch'],
                   stdout=PIPE, stderr=STDOUT,
                   preexec_fn=lambda: os.setuid(0)  # as daemon
                  )
# wait until ES has started
! sleep 30
于 2021-12-07T00:11:09.383 回答