8

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

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
4

3 回答 3

24

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

于 2011-09-19T16:41:59.437 回答
2

quit can be found in pygame.locals import *

Usage:

for event in pygame.event.get():
    if event.type == QUIT:
        pygame.quit()
        sys.exit()
于 2013-02-03T03:14:42.990 回答
1
def quit():
    sys.exit()


self.quit_button = Button(self, text="QUIT",command = quit)
于 2018-08-12T21:45:52.887 回答