os.popen

os.popen() doesn't work when the CWD is a UNC path like \\hostname\dirname\....

The call to os.popen() will appear to succeed, but subsequent calls to read/write the returned pipe will result in an IOError: invalid parameter exception.

This failure is not specific to py2exe as it will happen anytime os.popen() is used with the CWD is a UNC path such as \\hostname\dirname\... rather than a DOS style path such as G:dirname. While this isn't specific to py2exe, the problem is rarely encountered unless a program has been distributed using something like py2exe and is being invoked by clicking on something on the network to which the user has browsed.

The underlying problem is due to a "feature" in cmd.exe documented at http://support.microsoft.com/kb/156276/EN-US/

The solution is to use subprocess.Popen() instead of os.popen(). However, subprocess.Popen() has its own Windows-related bug which requires working around. See the Py2ExeSubprocessInteractions page for examples on working around subprocess.Popen bugs that show up when using py2exe.