【问题标题】:Kivy code working fine from the CMD python shell but not from a file saved at Desktop or any locationKivy 代码在 CMD python shell 中可以正常工作,但不能从保存在桌面或任何位置的文件中正常工作
【发布时间】:2015-11-12 18:07:52
【问题描述】:
from kivy.app import App
from kivy.uix.label import Label

class simple(App):
    def build(self):
        return Label(text = "Hello World")

if __name__ == "main__":
    simple().run()

上面的代码在 python CMD shell 中编写时可以正常工作,但是当保存在 文件 中时,此代码无法正常工作。

CMD python shell上:

来自 IDLE、Sublime Text 和不同的文本编辑器(文件保存在桌面上):

【问题讨论】:

标签: python kivy


【解决方案1】:

这是我自己的问题的答案。问题出在python路径上。因为我在桌面上创建文件。它没有正确读取 python 或特别是 kivy 的路径。解决方案是在 python 目录内的目录中创建或保存项目。它对我有用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-13
    • 1970-01-01
    • 2021-12-13
    • 2013-07-19
    相关资源
    最近更新 更多