'Cannot run system command

I am trying to zip a folder using python. The following command works from command prompt:

7z a C:\\Temp\\ C:\\Temp\\

But the following only show an error code of 1:

os.system("7z a C:\\Temp\\ C:\\Temp\\")

subprocess.call(["7z a C:\\Temp\\ C:\\Temp\\"], shell=True)

os.system("C:\Program Files\7-Zip\7z.exe a C:\\Temp\\ C:\\Temp\\")

Calling exe's with full path to them works for me well with the above approaches. Could anyone suggest a solution?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source