获取 Errno 13:作为 root 用户的权限被拒绝

发布于 2025-01-10 09:45:44 字数 1665 浏览 0 评论 0原文

所以基本上,我只想加载与脚本位于同一文件夹中的国际象棋引擎,

_, engine = await chess.engine.popen_uci('./engine')

这有什么问题吗?我以 root 用户身份运行该脚本。

另外,如果我仅从 'engine' 加载,它会说文件不存在。

UPT:收到此错误

 _, self.engine = await chess.engine.popen_uci(r'' + os.path.join(os.getcwd(), 'engine'))
  File "/usr/local/lib/python3.8/dist-packages/chess/engine.py", line 2642, in popen_uci
    transport, protocol = await UciProtocol.popen(command, setpgrp=setpgrp, **popen_args)
  File "/usr/local/lib/python3.8/dist-packages/chess/engine.py", line 1214, in popen
    return await asyncio.get_running_loop().subprocess_exec(cls, *command, **popen_args)  # type: ignore
  File "/usr/lib/python3.8/asyncio/base_events.py", line 1630, in subprocess_exec
    transport = await self._make_subprocess_transport(
  File "/usr/lib/python3.8/asyncio/unix_events.py", line 197, in _make_subprocess_transport
    transp = _UnixSubprocessTransport(self, protocol, args, shell,
  File "/usr/lib/python3.8/asyncio/base_subprocess.py", line 36, in __init__
    self._start(args=args, shell=shell, stdin=stdin, stdout=stdout,
  File "/usr/lib/python3.8/asyncio/unix_events.py", line 789, in _start
    self._proc = subprocess.Popen(
  File "/usr/lib/python3.8/subprocess.py", line 858, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.8/subprocess.py", line 1704, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: '/root/ChessBot/engine'```

So basically, I just want to load chess engine which is in the same folder with script

_, engine = await chess.engine.popen_uci('./engine')

What is wrong with this? I am running the script as a root user.

Also, if I load from just 'engine', it says file doesn't exist.

UPT: getting this error

 _, self.engine = await chess.engine.popen_uci(r'' + os.path.join(os.getcwd(), 'engine'))
  File "/usr/local/lib/python3.8/dist-packages/chess/engine.py", line 2642, in popen_uci
    transport, protocol = await UciProtocol.popen(command, setpgrp=setpgrp, **popen_args)
  File "/usr/local/lib/python3.8/dist-packages/chess/engine.py", line 1214, in popen
    return await asyncio.get_running_loop().subprocess_exec(cls, *command, **popen_args)  # type: ignore
  File "/usr/lib/python3.8/asyncio/base_events.py", line 1630, in subprocess_exec
    transport = await self._make_subprocess_transport(
  File "/usr/lib/python3.8/asyncio/unix_events.py", line 197, in _make_subprocess_transport
    transp = _UnixSubprocessTransport(self, protocol, args, shell,
  File "/usr/lib/python3.8/asyncio/base_subprocess.py", line 36, in __init__
    self._start(args=args, shell=shell, stdin=stdin, stdout=stdout,
  File "/usr/lib/python3.8/asyncio/unix_events.py", line 789, in _start
    self._proc = subprocess.Popen(
  File "/usr/lib/python3.8/subprocess.py", line 858, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.8/subprocess.py", line 1704, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: '/root/ChessBot/engine'```

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

血之狂魔 2025-01-17 09:45:44

如果我们检查文档,在 部分,您可以看到 path 是从 root 分配的,如下所示:

r"C:\Users\xxxxx\Downloads\stockfish_14_win_x64\stockfish_14_win_x64_avx2.exe"
“/usr/bin/stockfish”

虽然你要使用的引擎与运行程序的文件夹位于同一文件夹中,但可以直接从安装Python的路径中获取路径,我建议使用_,engine =而是等待 chess.engine.popen_uci(r''+os.path.join(os.getcwd(), 'engine'))

If we check documentation, in the playing section, you can see that the paths are assigned from the root like this:

r"C:\Users\xxxxx\Downloads\stockfish_14_win_x64\stockfish_14_win_x64_avx2.exe"
or "/usr/bin/stockfish".

Although the engine you want to use is in the same folder where you run the program, the path may be obtained directly from the path where Python is installed, I would recommend using _, engine = await chess.engine.popen_uci(r''+os.path.join(os.getcwd(), 'engine')) instead.

∞琼窗梦回ˉ 2025-01-17 09:45:44

现在我自己解决了这个问题。需要在引擎文件上执行此操作

$ chmod 755 engine

因此基本上,它将文件权限更改为所需的权限。

Resolved this by myself now. Need to execute this on engine file

$ chmod 755 engine

So basically, it changes files permissions to the required ones.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文