'subprocess.Popen Argument list is too long

I use

    proc = subprocess.Popen(cmd,
                            stdin=subprocess.PIPE,
                            stdout=subprocess.PIPE,
                            stderr=subprocess.STDOUT,
                            shell=shell,
                            universal_newlines=False,
                            env=env)

And the code fails with the exception

 File "subprocess.py", line 623, in __init__
 File "subprocess.py", line 1141, in _execute_child
 OSError: [Errno 7] Argument list too long

I found that my command length was really huge and hence this fails. And now I have correct it. However, I'm trying to find what is the maximum length of the command string that I can pass to subprocess Popen.



Solution 1:[1]

This is OS dependent. In windows your options are to try powershell or to find a different way of passing arguments to the application you are calling.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Clarus