I had this error because I was providing a string of arguments to subprocess.call
instead of an array of arguments. To prevent this, use shlex.split
:
import shlex, subprocess
command_line = "ls -a"
args = shlex.split(command_line)
p = subprocess.Popen(args)