开发者

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 fi开发者_JAVA技巧le 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.


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.


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜