subprocess.CalledProcessError In python when using unrar
Question: Python IDLE shows an error when I am trying to extract files using
winrar(UnRAR.exe):

    
    
    "Traceback (most recent call last):
      File "<pyshell#32>", line 1, in <module>
        response=subprocess.check_output(['"C:\\Users\\B74Z3\\Desktop\\Test\\UnRAR.exe" e -p123 "C:\\Users\\B74Z3\\Desktop\\Test\\Test.rar"'], shell=True)
      File "C:\Program Files\Python 3.5\lib\subprocess.py", line 629, in check_output
        **kwargs).stdout
      File "C:\Program Files\Python 3.5\lib\subprocess.py", line 711, in run
        output=stdout, stderr=stderr)
    subprocess.CalledProcessError: Command '['"C:\\Users\\B74Z3\\Desktop\\Test\\UnRAR.exe" e -p123 "C:\\Users\\B74Z3\\Desktop\\Test\\Test.rar"']' returned non-zero exit status 1"
    

* * *

What is the problem with the Code:

    
    
    import subprocess
    response=subprocess.check_output(['"C:\\Users\\B74Z3\\Desktop\\Test\\UnRAR.exe" e -p123 "C:\\Users\\B74Z3\\Desktop\\Test\\Test.rar"'], shell=True)
    


Answer: I'd comment on this, but I don't have enough reputation to do so.

Try running the command without the shell interface, that is,

    
    
    response=subprocess.check_output(["""C:\Users\B74Z3\Desktop\Test\UnRAR.exe""", "e", "-p123', """C:\Users\B74Z3\Desktop\Test\Test.rar"""])
    

I've also remove the complexity of adding additional backslashes from your
command by using triple quotes. This is almost more precise in that you know
exactly what command and arguments is being run.

Also on windows the shell=True is not needed unless you're running a shell
built in command, <https://docs.python.org/3/library/subprocess.html#popen-
constructor>:

> On Windows with shell=True, the COMSPEC environment variable specifies the
> default shell. The only time you need to specify shell=True on Windows is
> when the command you wish to execute is built into the shell (e.g. dir or
> copy). You do not need shell=True to run a batch file or console-based
> executable.

