Pyinstaller,NameError:未定义全局名称'quit'

时间:2011-09-19 16:36:29

标签: python pyinstaller

我有一个运行得很好的python脚本,但是在运行pyinstaller之后,当我使用quit()exit()命令时,我得到以下内容:

Makespec文件:

# -*- 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 )

这是我在运行应用程序后看到的内容:

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

3 个答案:

答案 0 :(得分:17)

那是因为没有quit命令。您正在寻找sys.exit

答案 1 :(得分:3)

quit可以在pygame.locals import *

中找到

用法:

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

答案 2 :(得分:2)

def quit():
    sys.exit()


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