Why does the "command not recognized" error occur only when the window is full?

My records app has a menu option to create a new blank list of records. When I open a sheet window, I can open new windows with no problem using subprocess.Popen () to do this.

However, on Windows (I haven't tested it on other OSs yet) if I open a new window then use the open file dialog to populate the fields with data from a file, I can no longer create new windows. When it is populated, Windows gives me

'foo.py' is not recognized as an internal or external command acting on a program or batch file.

I don't understand what could be causing Windows to suddenly not recognize the Popen () call. I don't have any code that would affect it in any way that I am aware of.

+1


source to share


2 answers


From the error message, it looks like you need to pass the full path "foo.py" to your Popen call. Usually just "foo.py" will look in your current working directory, but this can be a little unpredictable on Windows I found. It seems that you are jumping with an open dialog box.

Second, just for good measure, you would think that you need to pass foo.py as an argument to the python.exe executable, rather than execute foo.py itself. Again, I would point this out along the way.



To be on the safe side, something like:

subprocess.Popen([r'C:\Python2.5\python.exe', r'C:\path\to\foo.py'])

      

+4


source


The suggested answer seems to have fixed the problem. I also figured out that I need to use os.name to determine which OS is being used, then I can use the correct path format to load the external Python file.



0


source







All Articles