Reputation: 31
I am using python and the codes are all worked well with non-portable version. Since I need to run the program on some computer that does not belong to me, which does not have installed python or such option available. I use portable python instead. However the codes previously works well now report error"WindowsError: [Error 3] The system cannot find the path specified". I checked it on my computer. It works smoothly without the above error. Anybody can give a clue?
The cmd I am using is :
p = subprocess.Popen(self.cmdStr, shell=False, stdout=subprocess.PIPE, stderr=file)
I am redirecting the stderr to a file I specified.
I also googled online. There seems to have an issue of "subprocess PATH semantics and portability". I am not sure whether this is the reason. Please help. Thank you.
Upvotes: 0
Views: 1259
Reputation: 75
subprocess.Popen(r"C:\Python27\python.exe",shell=True) can work correctly.
Upvotes: 0
Reputation: 14910
Ah, the problem is in the cmdStr variable. You must use absolute paths, or else have the user the process is running under have an appropriately setup PATH system variable. That or you have shell=False, which can cause problems in the subprocess module. Check the documentation for issues concerning paths etc.
Upvotes: 1