I had a problem with calling a python 2.7 script with subprocess module methods in a Debian linux WM. The file path had parentheses and spaces in it, and even using various methods described here (Processing file paths with parentheses with Python subprocess; Windows path in Python), setting shell to True or False, using a string as input (with raw strings, escaped strings by hand or by re.escape()) or as a list of arguments, but I could not get it to work, so I resorted to rm and renaming my files replacing the parentheses with underscores. This worked then but I am not satisfied with getting stuck on such a problem.
So I am trying in jupyter notebook with Python 3.6 and Windows, to try and find whether if I am really stupid or if there is a configuration problem.
Here are my observations, below with be my understanding. Don't hesitate to use it for helping yourself or to comment
proc = sp.Popen("help", stdout =sp.PIPE, shell = True)
proc = sp.Popen("help", stdout =sp.PIPE, shell = False)
#both works
##OK!>
basicproc2_1 = sp.Popen(['md', 'basictest2_1'], shell=True, stdout =sp.PIPE)
#OK
#basicproc2_2 = sp.Popen(['md', 'basictest2_2'], shell=False, stdout =sp.PIPE)
#throws FileNotFoundError
##Quoted paths,escaped or not; shell False or True
###input as a list
#proc = sp.Popen(['md', '"test1 (1)"'], shell=False, stdout =sp.PIPE)
#throws FileNotFoundError
proc2_1 = sp.Popen(['md', '"test2 (1)"'], shell=True, stdout =sp.PIPE)
#create directory "(1)" which is stupid
proc2_2 = sp.Popen(['md', '"test2_2"'], shell=True, stdout =sp.PIPE)
#doesn't create directory either
#proc3 = sp.Popen(['md', '"test3\ \(1\)"'], shell=False, stdout =sp.PIPE)
#throws FileNotFoundError
proc4 = sp.Popen(['md', '"test4\ \(1\)"'], shell=True, stdout =sp.PIPE)
#doesn't throw FileNotFoundError but doesn't create any file or directory, which is by far the strangest result
###input as a string
#proc5 = sp.Popen(['md "test5 (1)"'], shell=False, stdout =sp.PIPE)
#throws FileNotFoundError
#proc6 = sp.Popen(['md "test6 (1)"'], shell=True, stdout =sp.PIPE)
#doesn't throw FileNotFoundError but doesn't create any file or directory, which is by far the strangest result
#proc7 = sp.Popen(['md "test7\ \(1\)"'], shell=False, stdout =sp.PIPE)
#throws FileNotFoundError
#proc8 = sp.Popen(['md "test8\ \(1\)"'], shell=True, stdout =sp.PIPE)
#doesn't throw FileNotFoundError but doesn't create any file or directory, which is by far the strangest result
##Unquoted paths,escaped or not; shell False or True
###input as a list
#proc9 = sp.Popen(['md', 'test9 (1)'], shell=False, stdout =sp.PIPE)
#throws FileNotFoundError
#OK!>
#proc10 = sp.Popen(['md', 'test10 (1)'], shell=True, stdout =sp.PIPE)
#create directory "test10 (1)" which is OK!!!!!!!!!!!!
#proc11 = sp.Popen(['md', 'test11\ \(1\)'], shell=False, stdout =sp.PIPE)
#throws FileNotFoundError
#proc12 = sp.Popen(['md', 'test12\ \(1\)'], shell=True, stdout =sp.PIPE)
#create 'test12' directory which is wrong
###input as a string
#proc13 = sp.Popen('md test13 (1)', shell=False, stdout =sp.PIPE)
#throws FileNotFoundError
#proc14 = sp.Popen('md test14 (1)', shell=True, stdout =sp.PIPE)
#create directories 'test14' and '(1)'
#proc15 = sp.Popen('md test15\ \(1\)', shell=False, stdout =sp.PIPE)
#throws FileNotFoundError
#proc16 = sp.Popen('md test16\ \(1\)', shell=True, stdout =sp.PIPE)
#create 'test16' directory which is wrong
#mixing input string and list (not doing the quoted versions)
#proc5 = sp.Popen(['md test17 (1)'], shell=False, stdout =sp.PIPE)
#throws FileNotFoundError
#proc6 = sp.Popen(['md test6 (1)'], shell=True, stdout =sp.PIPE)
#doesn't throw FileNotFoundError but doesn't create any file or directory, which is by far the strangest result
#proc7 = sp.Popen(['md test7\ \(1\)'], shell=False, stdout =sp.PIPE)
#throws FileNotFoundError
#proc8 = sp.Popen(['md test8\ \(1\)'], shell=True, stdout =sp.PIPE)
#doesn't throw FileNotFoundError but doesn't create any file or directory, which is by far the strangest result
Hence, as long as you have arguments, shell = False should not be considered (contrary to what I read before). It is better to use input as a list of unquoted, unescaped argument. Escapes will mess with the result and quoted inputs won't be taken into account.
I will try on linux now to check whether behavior is comparable or not.