开发者

There is no spawnl function in python 2.6?

I just noticed that my old codes written in python 2.5 does not work now. I am in python 2.6 btw.

>>> os.spawnl开发者_StackOverflow中文版(os.P_NOWAIT,"setup.exe")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "c:\python26\lib\os.py", line 612, in spawnl
    return spawnv(mode, file, args)
OSError: [Errno 22] Invalid argument
>>>

Any clue? or do you have any working sample of os.spawn* with NOWAIT option.

Update:

Even I put full path in os.spawnl(), Its still error.


thrope is right about subprocess being preferred. But the spawn* stuff is still there in 2.6. In fact, you can see that in your error message. Your first arg seems to be valid. I'd check the second arg, which is the path.


I got it work by adding DUMMY parameter finally, a bit funky though

This is not working

os.spawnl(os.P_NOWAIT,"Setup.exe")

This is also not working

os.spawnl(os.P_NOWAIT,"Setup.exe","")

But this is working

os.spawnl(os.P_NOWAIT,"Setup.exe","DUMMY")

Thanks all anyway.


I think its recommended to use the subprocess module these days rather than the os.spawn* functions. (I can't reproduce your problem, but I'm not on windows).


A Google search brings up this page about the same problem happening when there is a space in the Python installation path. I couldn't reproduce it here, but maybe it's the problem?

In any case, according to MS documentation this error value (EINVAL) should only be returned if the mode argument is invalid, which isn't the case here.


os.spawnl() requires full path to executable, while os.spawnlp() uses PATH environment variable to find it.

Update: Also it's common error to use unescaped backslashes in the path literal (try printing it to see whether it's interpreted right).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜