【问题标题】:PermissionError: [Errno 13] Permission denied and Subprocess errorPermissionError: [Errno 13] 权限被拒绝和子进程错误
【发布时间】:2021-02-24 11:32:25
【问题描述】:
    PermissionError                           Traceback (most recent call last)
<ipython-input-8-bab992cc7bb5> in <module>()
     67 
     68 if __name__ == "__main__":
---> 69     main()

/content/gdrive/My Drive/LORE/pyyadt.py in fit(df, class_name, columns, features_type, discrete, continuous, filename, path, sep, log)
     32     cmd = 'yadt/dTcmd -fd %s -fm %s -sep %s -d %s' % (
     33         data_filename, names_filename, sep, tree_filename)
---> 34     output = subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT)
     35     # cmd = r"dTcmd -fd %s -fm %s -sep '%s' -d %s" % (
     36     #     data_filename, names_filename, sep, tree_filename)

/usr/lib/python3.6/subprocess.py in check_output(timeout, *popenargs, **kwargs)
    354 
    355     return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
--> 356                **kwargs).stdout
    357 
    358 

/usr/lib/python3.6/subprocess.py in run(input, timeout, check, *popenargs, **kwargs)
    421         kwargs['stdin'] = PIPE
    422 
--> 423     with Popen(*popenargs, **kwargs) as process:
    424         try:
    425             stdout, stderr = process.communicate(input, timeout=timeout)

/usr/lib/python3.6/subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors)
    727                                 c2pread, c2pwrite,
    728                                 errread, errwrite,
--> 729                                 restore_signals, start_new_session)
    730         except:
    731             # Cleanup if the child failed starting.

/usr/lib/python3.6/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)
   1362                         if errno_num == errno.ENOENT:
   1363                             err_msg += ': ' + repr(err_filename)
-> 1364                     raise child_exception_type(errno_num, err_msg, err_filename)
   1365                 raise child_exception_type(err_msg)
   1366 

PermissionError: [Errno 13] Permission denied: 'yadt/dTcmd'

我无法访问该文件,因此脚本没有运行。在虚拟环境中也尝试了不同的 python 版本。对此子流程错误有任何帮助吗?

文件“dTcmd”没有扩展名。

【问题讨论】:

  • dTcmd 有 +x 位吗?它是带有 shebang 的脚本吗?而且 shebang 可能指向运行 python 脚本的用户无权访问的某些解释器?
  • 我不确定,但我不认为它是一个可执行文件。我正在尝试通过运行文件 test_lore.py 来运行此 repo 以检查结果 (github.com/riccotti/LORE) 如果您可以请告诉我它是否为您运行? @rasjani

标签: python subprocess


【解决方案1】:

看起来您正在尝试执行名为 yadt/dTcmd 的文件,但它并未标记为可执行文件。添加执行权限(适用于所有用户),如下所示:

chmod a+x yadt/dTcmd

【讨论】:

  • 我认为该文件不可明确执行,我认为它在第 32 行尝试获取时存储了一些数据。我正在尝试通过运行脚本 test_lore.py 来检查结果 (github.com/riccotti/LORE) 如果可以请检查它是否为你运行?
  • 不,第 32 行肯定会尝试执行它。它是您链接到的存储库中的 ELF 可执行文件。通常 Git(在 Linux 上)会正确保留可执行位,但如果您将 repo 下载为 ZIP 文件,您有时需要自己将它们添加回来。
  • 知道了,我之前在 mac 上下载了 zip。在 ubuntu 上通过 Git 运行有效!非常感谢。
猜你喜欢
  • 2015-07-17
  • 2016-07-25
  • 2018-11-18
  • 2020-02-07
  • 1970-01-01
  • 2020-07-01
  • 2016-11-12
  • 2019-11-09
  • 2020-06-06
相关资源
最近更新 更多