为什么我的 Kivy windows 可执行文件不是 运行?

Why is my Kivy windows Executable not running?

我制作了一个 kivy 应用程序并将其打包为一个可执行文件,但由于某种原因,该可执行文件只打开了一瞬间然后关闭而没有显示任何内容。我确信我的代码 none 存在缺陷,因为它在我的文本编辑器中 运行 时有效,我该怎么做才能解决这个问题?

规格文件-

from kivy_deps import sdl2, glew

# -*- mode: python ; coding: utf-8 -*-

block_cipher = None


a = Analysis(['C:\Users\Admin\Assignment\Info_Tech_Assignment.py'],
             pathex=['C:\Users\Admin\Desktop\Tech'],
             binaries=[],
             datas=[],
             hiddenimports=[],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          [],
          exclude_binaries=True,
          name='Info_Tech',
          debug=False,
          bootloader_ignore_signals=False,
          strip=False,
          upx=True,
          console=True )
coll = COLLECT(exe, Tree('C:\Users\Admin\Assignment\'),
               a.binaries,
               a.zipfiles,
               a.datas,
               *[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)],
               strip=False,
               upx=True,
               upx_exclude=[],
               name='Info_Tech')

Python代码-

import kivy
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.label import Label
from kivy.uix.textinput import TextInput
from kivy.uix.screenmanager import Screen, ScreenManager
from kivy.properties import StringProperty, ObjectProperty
import webbrowser
from kivy.uix.image import Image
from kivy.core.window import Window
import keyboard



class Login(Screen):
    def validate(self):
        user = self.ids.input_1
        pwd = self.ids.input_pwd
        info = self.ids.info

        uname = user.text
        passw = pwd.text   

        
        if uname == '' or passw == '':
            info.text = '[color=#FF0000]Username or password needed[/color]'
        else:
            if uname == 'Savant' and passw == 'root':
                self.parent.current = 'contentpage'
            else:
                    info.text = '[color=#FF0000]Username or password is invalid[/color]'
    pass

class TableOfContents(Screen):
    pass

class WorldWideWeb(Screen):
    def web(self):
        webbrowser.open("https://en.wikipedia.org/wiki/Tim_Berners-Lee")
    pass

class HypertextMarkupLanguage(Screen):
    pass

class HypertextTransferProtocol(Screen):
    pass

class Hyperlinks(Screen):
    pass

class WebServer(Screen):
    pass

class Webpage(Screen):
    pass

class FileTransferProtocol(Screen):
    pass

class WebBrowser(Screen):
    pass

class UniformResourceLocator(Screen):
    pass

class UploadandDownload(Screen):
    pass

class Email(Screen):
    pass

class Pictures(Screen):
    pass

class References(Screen):
    pass

class WindowManager(ScreenManager):
    data_dir = App().user_data_dir
    
    pass

kv = Builder.load_file("rtech.kv")

class info(App):
    def build(self):
        return kv

if __name__ == "__main__":
    Window.maximize()
    info().run()

keyboard.wait('esc')

我发现了这个问题,这是因为我是 运行 build 文件夹可执行文件而不是 dist 文件夹可执行文件,显然这是人们常犯的错误。