【问题标题】:twisted.internet.reactor.spawnProcess raises OSError(13, 'Permission denied')twisted.internet.reactor.spawnProcess 引发 OSError(13, 'Permission denied')
【发布时间】:2011-08-05 17:23:38
【问题描述】:

当我尝试通过 `twisted.internet.reactor.spawnProcess' 运行 python 脚本时:

from twisted.internet import protocol, reactor

class ProcessProtocol(protocol.ProcessProtocol):
    def connectionMade(self):
        self.transport.closeStdin()

    def childDataReceived(self, childFD, data):
        print data

def main():
    proto = ProcessProtocol()
    cmd = ['/var/projects/python/worker.py']
    reactor.spawnProcess(proto, cmd[0], cmd)

if __name__ == "__main__":
    exit(main())

我收到以下错误:

Upon execvpe /var/projects/python/worker.py ['/var/projects/python/worker.py', '5'] in environment id 29011152
:Traceback (most recent call last):
  File "/usr/local/lib/python2.6/dist-packages/Twisted-11.0.0-py2.6-linux-x86_64.egg/twisted/internet/process.py", line 414, in _fork
    executable, args, environment)
  File "/usr/local/lib/python2.6/dist-packages/Twisted-11.0.0-py2.6-linux-x86_64.egg/twisted/internet/process.py", line 460, in _execChild
    os.execvpe(executable, args, environment)
  File "/usr/lib/python2.6/os.py", line 353, in execvpe
    _execvpe(file, args, env)
  File "/usr/lib/python2.6/os.py", line 368, in _execvpe
    func(file, *argrest)
OSError: [Errno 13] Permission denied

【问题讨论】:

  • 你确定你有权限执行'/var/projects/python/worker.py'吗?
  • 您是否以 root 身份运行脚本?如果没有,/var/projects/python/worker.py 文件是否具有被用于运行脚本的用户读取的正确权限?

标签: python twisted spawn twisted.internet


【解决方案1】:

您可能没有执行'/var/projects/python/worker.py' 的权限,或者该脚本的执行位未设置。做一个ls -l /var/projects/python/worker.py 并检查它?

【讨论】:

猜你喜欢
  • 2020-06-21
  • 1970-01-01
  • 2016-08-07
  • 2017-07-15
  • 2015-11-26
  • 1970-01-01
  • 1970-01-01
  • 2012-06-16
相关资源
最近更新 更多