Permission denied in colab

1k Views Asked by At

I want to use stockfish in my colab notebook. I first tried with the chess.engine.SimpleEngine.popen_uci() command, which seems to be outdated, since module 'chess.engine' has no attribute 'SimpleEngine'

So I tried with stockfish itself:

from stockfish import Stockfish

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

Here I always get the error:

Permission denied: '/usr/local/lib/python3.7/dist-packages/stockfish'

I googled for it and came up with some good tries:

I tried with !chmod +x '/usr/local/lib/python3.7/dist-packages/stockfish' which compiled, but didn't resolved the problem, and !chmod +x 'stockfish', which didn't find the folder.

So how exactly do I give permission to use the stockfish folder?

1

There are 1 best solutions below

0
On

You need to set the os.setuid to 0 like this code below:

! 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