1
proc = subprocess.Popen(cmd,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
shell=shell,
universal_newlines=False,
env=env)
和代碼失敗,異常
File "subprocess.py", line 623, in __init__
File "subprocess.py", line 1141, in _execute_child
OSError: [Errno 7] Argument list too long
我發現我的命令長度真的很龐大,因此失敗。現在我有正確的了。但是,我試圖找到什麼是我可以傳遞給子進程Popen的命令字符串的最大長度。
最大長度取決於操作系統 - 也取決於環境變量的大小,因爲命令行參數共享相同的空間。這是一個操作系統限制,而不是Python的限制,並且沒有單一的,正確的正確的恆定值,我們可以給你。 –
可能的重複[什麼是args參數的subprocess.Popen最大長度?](http://stackoverflow.com/questions/2381241/what-is-the-subprocess-popen-max-length-of-the- args參數) –
另請參閱http://www.in-ulm.de/~mascheck/various/argmax/ –