I'm coding a program which uses os.path.abspath(os.path.dirname(__file__)))
to locate its config file and it works like a charm when I use it in pure Python, but as soon as I compile it to .exe using py2exe I get this error:
Traceback (most recent call last):
File (main.py, line 17, in <module>
NameError: name '__file__' is not defined
Exactly, line 17 is:
if os.path.isfile("%s/config.cfg" % os.path.abspath(os.path.dirname(__file__))):
Why this happens and how I can overcome this problem?
Thanks in advance! :)