[Tutor] file/subprocess error

Alan Gauld alan.gauld at btinternet.com
Thu Jun 11 00:57:35 CEST 2009

"Essah Mitges" <e_mitges at hotmail.com> wrote 
> So no one is confused about the error i screenshot it 


> I am not sure of the problem

It says it can't find the file.
Does a file

C:\Users\John Doe\Desktop\WODDS\WODDS\gamelib\data\up-1.png

actually exist? And is it readable by the user running the program?

> When I run the game outside the menu it works fine 

Are you running it from the same directory?

> but when I call it as a child window it start then the modules 
> attached cannnot load the games images which couse this 
> error is there a subprocess command to fix this

No, you need to set up the correct environment for the game 
to run before calling subprocess.

However as I and others have pointed out this is almost 
certainly the wrong way to approach your problem, even if 
you can get it to work! You would be better putting the game 
code into a function in Utilities.py and then importing that into 
your menu module. You can then call the game function

import Utilities

# menu code here


And so that you can still ru n it as Utilities.py add a clause 
at the end of IUtilities.py like

if __name__ == "__main__":


Alan Gauld
Author of the Learn to Program web site

More information about the Tutor mailing list