how to get the path of a module (myself) ?

Vlastimil Brom vlastimil.brom at
Tue Jun 2 11:11:30 CEST 2009

2009/6/2 Stef Mientki <stef.mientki at>:
> and the files generated by Py2Exe, don't work at all.
> Through this discussion, I discovered another problem,
> because __file__ isn't the current file,
> I can't run 1 module(file) from another module (file) .
> --

There are already  answers regarding other more topical issues with
the initial problem; but just in case the main problem would be the
use of __file__ ...
It seems, that the exe files generated from py2exe don't recognise
this variable;
sometimes I used code like

except NameError: # py2exe
    __file__ = sys.path[0]

cf. e.g.

I'm not sure, whether there are any drawbacks, but it works in the
respective context (accessing text and image files in parallel


More information about the Python-list mailing list