[Tutor] Windows Linux Popen

eryksun eryksun at gmail.com
Thu Jun 27 14:41:58 CEST 2013


On Thu, Jun 27, 2013 at 8:10 AM, Matthew Ngaha <chigga101 at gmail.com> wrote:
> i have more than 1 issue all involving things in the title. 1st i use
> windows vista and was following along the pytest tutorial. the 1st
> issue is with windows and SubProcess.Popen(). Everytime i run the test
> which includes this line:
>
> p = subprocess.Popen(
>                 ['python3', 'echo_server.py'])
>
> WindowsError: [Error 2] The system cannot find the file specified

The error is telling you that Windows can't find "python3". The exe is
named python.exe on Windows, not python3.exe, and it will have to be
on your system PATH to be invoked like that. If you want to run the
script with the current interpreter, you can use sys.executable. For
example:

    >>> subprocess.Popen(
    ...   [sys.executable, '-c', r'print("spam")']).wait()
    spam
    0


More information about the Tutor mailing list