Problem running compiled Python script -


this question has answer here:

so have compiled python script py2exe according this answer. there no errors during compilation, went fine.

when run script cmd this:

c:\users\richard\dist\backprop3.exe 60 

this output get:

c:\users\richard>c:\users\richard\dist\backprop3.exe 60 traceback (most recent call last):   file "backprop3.py", line 209, in <module>   file "backprop3.py", line 175, in demo nameerror: global name '__file__' not defined  c:\users\richard> 

which referring line:

image = image.open( os.path.dirname( os.path.abspath( __file__ ) )+"/backprop-input.bmp" ) 

that line loads image current directory. problem?

__file__ not work within py2exe. because module inside .exe , there nothing set __file__ give python file.

see http://www.py2exe.org/index.cgi/whereami techniques of dealing this.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -