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

Gabriel Genellina gagsl-py2 at
Wed Jun 3 07:32:03 CEST 2009

En Tue, 02 Jun 2009 06:11:30 -0300, Vlastimil Brom
<vlastimil.brom at> escribió:

> [...] 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
> try:
>     __file__
> except NameError: # py2exe
>     __file__ = sys.path[0]

I think you meant __file__ = sys.argv[0]

> cf. e.g.  

That's a rather old post. The "right" way to obtain a resource from a
package is using pkgutil.get_data(), and py2exe should support it by now.
(I haven't tested, but I think it does).

Gabriel Genellina

More information about the Python-list mailing list