2

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.

Joe
  • 1,312
  • 20
  • 24
  • 1
    The maximum length is OS-dependent -- and also depends on the size of your environment variables, since command-line arguments share the same space. This is an OS limit, not a Python limit, and there is no single, canonically correct constant value we can give you. – Charles Duffy Mar 13 '14 at 16:57
  • 1
    See also http://www.in-ulm.de/~mascheck/various/argmax/ – Charles Duffy Mar 13 '14 at 17:01
  • This one will help https://stackoverflow.com/questions/24788292/intermittent-oserror-errno-7-argument-list-too-long-with-short-command-12 – Love Garg Nov 18 '19 at 16:31

1 Answers1

0

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.

Clarus
  • 2,259
  • 16
  • 27