Mua
Mua

Reputation: 31

Python (Portable 2.5) subprocess report problem "WindowsError: [Error 3] The system cannot find the path specified"

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

Answers (3)

john2000
john2000

Reputation: 75

subprocess.Popen(r"C:\Python27\python.exe",shell=True) can work correctly.

Upvotes: 0

john2000
john2000

Reputation: 75

Can 'cmd /c cmdstr' run correctly on windows?

Upvotes: 0

Spencer Rathbun
Spencer Rathbun

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

Related Questions