gpt4 book ai didi

python - 无法运行简单的程序 - Python - Kivy - Ubuntu

转载 作者:行者123 更新时间:2023-12-04 19:08:40 26 4
gpt4 key购买 nike

大家好,我正在尝试直接从控制台运行一个简单的代码:python test.py代码是这样的:

import kivy.app
import kivy.uix.label

class TestApp(kivy.app.App):
def build(self):
return kivy.uix.label.Label(text="Hello World")

app = TestApp()
app.run()
当我尝试运行它时,它会抛出这个错误:
[WARNING] [Deprecated  ] Python 2 Kivy support has been deprecated. The Kivy release after 1.11.0 will not support Python 2 anymore
[INFO ] [Factory ] 184 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_pil, img_gif (img_pygame, img_ffpyplayer ignored)
[INFO ] [Text ] Provider: pil(['text_pygame'] ignored)
[CRITICAL] [Window ] Unable to find any valuable Window provider. Please enable debug logging (e.g. add -d if running from the command line, or change the log level in the config) and re-run your app to identify potential causes
egl_rpi - ImportError: cannot import name bcm
File "/home/omar/.local/lib/python2.7/site-packages/kivy/core/__init__.py", line 63, in core_select_lib
fromlist=[modulename], level=0)
File "/home/omar/.local/lib/python2.7/site-packages/kivy/core/window/window_egl_rpi.py", line 12, in <module>
from kivy.lib.vidcore_lite import bcm, egl

pygame - ImportError: No module named pygame
File "/home/omar/.local/lib/python2.7/site-packages/kivy/core/__init__.py", line 63, in core_select_lib
fromlist=[modulename], level=0)
File "/home/omar/.local/lib/python2.7/site-packages/kivy/core/window/window_pygame.py", line 13, in <module>
import pygame

x11 - ImportError: No module named window_x11
File "/home/omar/.local/lib/python2.7/site-packages/kivy/core/__init__.py", line 63, in core_select_lib
fromlist=[modulename], level=0)

[CRITICAL] [App ] Unable to get a Window, abort.
我一直在寻找一些解决方案,其中一些是为 Kivy 安装先决条件,但是当我尝试执行以下行时:
python -m pip install docutils pygments pypiwin32 kivy.deps.sdl2 kivy.deps.glew; 
python -m pip install kivy.deps.gstreamer
它向我抛出了下一个错误:
ERROR: Could not find a version that satisfies the requirement kivy.deps.sdl2 (from versions: none)
ERROR: No matching distribution found for kivy.deps.sdl2
...等等。
当我在 Windows 中运行我的所有代码时,我没有问题,但在 Ubuntu 上我不知道该怎么做。
我在 Ubuntu 18.04.4 LTS 上运行,我不知道我应该提供什么信息。

最佳答案

我相信这是因为您使用的是 python2 而不是 python3。 Linux 标配有 python2,即使你安装了 python3,如果你不明确说话,它也会与 python2 一起运行。
1-确保您安装了python3。
2-运行python3 test.py

关于python - 无法运行简单的程序 - Python - Kivy - Ubuntu,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62663181/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com