问题描述
我正在使用 killableprocess 包(建立在子进程之上)来运行进程每当我在脚本中运行killableprocess.Popen(command)"这段代码时,我都会收到以下错误:
I'm using the killableprocess package (built on top of subprocess) for running processes Whenever I run the "killableprocess.Popen(command)" piece of code in my script I get the following error:
File "killableprocess.py", line 157, in _execute_child
winprocess.AssignProcessToJobObject(self._job, hp)
File "winprocess.py", line 37, in ErrCheckBool
raise WinError()
WindowsError [error 5] Access is denied
Exception TypeError: "'NoneType' object is not callable" in <bound method AutoHANDLE.__del__ of <AutoHANDLE object at 0x025D42B0>> ignored
但是当我从 python 交互式控制台 (python 2.6) 运行它时,它工作正常.这可能意味着当我从脚本运行它时存在权限问题,但我不知道如何解决它们.我尝试从以管理员身份运行的 cmd 运行脚本,但没有帮助.尝试寻找类似的帖子,但没有找到任何好的解决方案.希望能在这里找到帮助我在 Windows 上运行,特别是 Windows 7 Ultimate x64,如果有帮助的话.
But when I run it from the python interactive console (python 2.6) it works fine. That probably means there are permission issues when I run this from the script, but I don't know how to solve them. I tried running the script from a cmd that I ran as administrator, but it didn't help. Tried looking for similar posts but didn't find any good solution. Hope to find some help here I'm running on Windows, specifically Windows 7 Ultimate x64, if it's any help.
谢谢
推荐答案
我通过切换到进程目录(我尝试使用inkscape)解决了我遇到的类似问题,它解决了我的问题
I solved a similar problem I had by switching to the process directory (I was trying to use inkscape) and it solved my problem
import subprocess
inkscape_dir=r"C:Program Files (x86)Inkscape"
assert os.path.isdir(inkscape_dir)
os.chdir(inkscape_dir)
subprocess.Popen(['inkscape.exe',"-f",fname,"-e",fname_png])
也许切换到进程目录也对你有用.
Maybe switching to the process directory will work for you too.
这篇关于WindowsError [错误 5] 访问被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!