Why would an “command not recognized” error occur only when a window is populated?

前端 未结 2 1261
被撕碎了的回忆
被撕碎了的回忆 2021-01-24 15:08

My record sheet app has a menu option for creating a new, blank record sheet. When I open a sheet window, I can open new windows without a problem, using subprocess.Popen() to d

2条回答
  •  失恋的感觉
    2021-01-24 15:32

    From the error message, it looks like you need to pass the full path of "foo.py" to your Popen call. Normally just having "foo.py" will search in your current working directory, but this can be a bit unpredictable on Windows, I have found. Yours seems to be jumping around with the open file dialog.

    Secondly, just for good measure, it would seem like you would need to pass foo.py as an argument to python.exe executable, rather than executing foo.py itself. Again, I would specify this by path.

    So to be safe, something like:

    subprocess.Popen([r'C:\Python2.5\python.exe', r'C:\path\to\foo.py'])
    

提交回复
热议问题