Python execvp错误

时间:2016-10-09 22:18:30

标签: python

我写了以下两段代码:

第一个叫做_Process.py

print("Hello Python!!")
closeInput = raw_input("Press Enter to exit")
print "Closing calledProcess"

第二个程序是call_Process.py,它调用上面的程序:

import os
import sys

program = "python"
print("Process Calling")
arguments = ["called_Process.py"]
os.execvp(program, (program,) + tuple(arguments))
print("Finished calling called_Process!!")

当我使用python 3.6.0在Windows上运行calling_Process.py时,出现以下错误:

Process Calling
Traceback (most recent call last):
  File "C:/Users/ND/Desktop/calling_Process.py", line 14, in <module>
    os.execvp(program, (program,) + tuple(arguments))
  File "C:\Users\ND\AppData\Local\Programs\Python\Python36\lib\os.py", line 623, in execvp
    _execvpe(file, args)
  File "C:\Users\ND\AppData\Local\Programs\Python\Python36\lib\os.py", line 668, in _execvpe
    raise last_exc.with_traceback(tb)
  File "C:\Users\ND\AppData\Local\Programs\Python\Python36\lib\os.py", line 658, in _execvpe
    exec_func(fullname, *argrest)
FileNotFoundError: [Errno 2] No such file or directory
>>> os.environ()
Traceback (most recent call last):
  File "<pyshell#6>", line 1, in <module>
    os.environ()
TypeError: '_Environ' object is not callable

有人可以帮助我了解导致此错误的原因吗?

0 个答案:

没有答案