Skip to content
Advertisement

Python subprocess returning exception

I have the following code that has been working until recently:

JavaScript

it calls the opt_module_v3.py and returns messages as the child process runs. When I run the main code, I’m getting the following exception:

JavaScript

Like I mentioned, this code was working before but I might have stuffed up since I’ve been working on improvements. Any clues on what could be happening here?

Advertisement

Answer

The documentation says the API is:

JavaScript

This means your command has to be put in a list.

in your code [path + 'opt_module_v3.py'] + vlist is interpreted as bufsize

instead of

self.popen = Popen('python', [path + 'opt_module_v3.py'] + vlist, stdout=PIPE, stderr=STDOUT, stdin=PIPE, universal_newlines=True, bufsize=1, startupinfo=si, env=env)

you should use something like

self.popen = Popen(['python', [path + 'opt_module_v3.py'] + vlist], stdout=PIPE, stderr=STDOUT, stdin=PIPE, universal_newlines=True, bufsize=1, startupinfo=si, env=env)

I think however you may additionaly need to concatenate your path to a string to make this work

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement