拆分对 sudo 的调用(出于@zzzrik 上面详述的所有原因):
>>> result = subprocess.call (["sudo /usr/bin/python","/home/hughdbrown/Dropbox/src/longwords.py"])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/subprocess.py", line 493, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1249, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
>>> result = subprocess.call (["sudo", "/usr/bin/python","/home/hughdbrown/Dropbox/src/longwords.py"])
[sudo] password for hughdbrown:
看?第二个正在工作,因为我收到提示输入密码。