简体   繁体   English

运行 pyinstaller 文件时会引发属性错误

[英]When running pyinstaller file it raises an attribute error

I am creating a kivy app in python. When I run the program in the text editor there is no error.我正在 python 中创建一个 kivy 应用程序。当我在文本编辑器中运行该程序时,没有错误。 But when I convert the file from.py to.exe using pyinstaller the following error is raised.但是,当我使用 pyinstaller 将文件从 .py 转换为 .exe 时,会出现以下错误。

Window.fullscreen = "auto"

# AttributeError: 'NoneType' object has no attribute 'fullscreen'

How do I fix it?我如何解决它?

Code:代码:

from kivy.core.window import Window

Window.fullscreen = 'auto'

App.run()

I looked everywhere but didn't get an answer on how to fix the problem.我到处看了看,但没有得到关于如何解决问题的答案。

Before compiling your code to.exe, you can also run it using python your_app.py .在将代码编译为 .exe 之前,您还可以使用python your_app.py运行它。 You are not going to see an error in your "text editor" (before running it) unless it's a typing error.你不会在你的“文本编辑器”中看到错误(在运行它之前),除非它是一个输入错误。

Anyway, your problem happens because you are trying to assign the value "auto" to "Window.fullscreen" before importing (which is why you are getting the NoneType error, as it doesn't exist yet)无论如何,您的问题发生是因为您试图在导入之前将值“auto”分配给“Window.fullscreen”(这就是为什么您收到 NoneType 错误,因为它尚不存在)

You should do this instead:你应该这样做:

from kivy.core.window import Window
Window.fullscreen = 'auto'

Do this before the App.run() method, and it should switch to fullscreen mode.在 App.run() 方法之前执行此操作,它应该切换到全屏模式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM