Pyinstaller, NameError: global name 'quit' is not defined

*爱你&永不变心* 提交于 2020-06-12 04:25:12

问题


I have a python script which runs just fine, however after running pyinstaller, I get the following when I use a quit() or exit() command:

Makespec file:

# -*- mode: python -*-
a = Analysis([os.path.join(HOMEPATH,'support/_mountzlib.py'), os.path.join(HOMEPATH,'support/useUnicode.py'), 'icinga.py'],
             pathex=['/home/user/projects/icinga_python/releases/onefile_v1.0'])
pyz = PYZ(a.pure)
exe = EXE( pyz,
          a.scripts,
          a.binaries,
          a.zipfiles,
          a.datas,
          name=os.path.join('dist', 'icinga'),
          debug=False,
          strip=False,
          upx=True,
          console=1 )

Here is what I see after I run the app:

Traceback (most recent call last):
  File "<string>", line 222, in <module>
  File "<string>", line 207, in main
  File "<string>", line 66, in icinga_mysql
  File "<string>", line 45, in checksanity
NameError: global name 'quit' is not defined

回答1:


That is because there is no quit command. You are looking for sys.exit.




回答2:


quit can be found in pygame.locals import *

Usage:

for event in pygame.event.get():
    if event.type == QUIT:
        pygame.quit()
        sys.exit()



回答3:


def quit():
    sys.exit()


self.quit_button = Button(self, text="QUIT",command = quit)


来源:https://stackoverflow.com/questions/7474291/pyinstaller-nameerror-global-name-quit-is-not-defined

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