cant get py2exe to work

元气小坏坏 提交于 2019-12-06 08:56:51
badNameHere

i have finally gotten this to work, using this question py2exe - generate single executable file

i found out i had to modify my setup file which now looks like this:

from distutils.core import setup
import py2exe, sys, os

sys.argv.append('py2exe')
#bundle files set to 2 because its a tkinter app
setup(
    options = {'py2exe': {'bundle_files': 2, 'compressed': True}},
    windows = [{'script': "workinghoursGUI.pyw"}],
    zipfile = None,
)

but then because in my code i was using os.path.dirname(os.path.realpath(__file__)) and py2exe doesnt support __file__, i found myself on this question How do I get the path of the current executed file in Python? and used ArtOfWarfare's answer to get the current path, which is:

from inspect import getsourcefile
from os.path import abspath
...
abspath(getsourcefile(lambda:0))
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!