Python 无限循环:“无限循环”;尝试第一次构建kivy以获取自定义cython文件:这可能会失败。。。工作:kivy/graphics/fbo.c:1:xx:warning:nul…“;

Python 无限循环:“无限循环”;尝试第一次构建kivy以获取自定义cython文件:这可能会失败。。。工作:kivy/graphics/fbo.c:1:xx:warning:nul…“;,python,python-3.x,kivy,buildozer,Python,Python 3.x,Kivy,Buildozer,我已经构建了一个小购物车,我可以使用我用Kivy(下面的代码)用Python编写的应用程序来控制它,但是当在虚拟Linux机器中使用Buildozer并使用以下命令时(Android手机插入我的计算机并启用USB调试): 它仍然卡在以下零件上: [INFO]: -> running python3 -c import sys; print(sys.path) [INFO]: Trying first build of kivy to get cython files: this

我已经构建了一个小购物车,我可以使用我用Kivy(下面的代码)用Python编写的应用程序来控制它,但是当在虚拟Linux机器中使用Buildozer并使用以下命令时(Android手机插入我的计算机并启用USB调试):

它仍然卡在以下零件上:

[INFO]:    -> running python3 -c import sys; print(sys.path)
[INFO]:    Trying first build of kivy to get cython files: this is expected to fail
[INFO]:    -> running python 3 setup.py build_ext -v
           working: kivy/graphics/fbo.c:1:xxxxxxx: warning nul...(and 38 more)
现在,整个消息保持不变大约1.5个小时,除了xxxxxxx,这是一个不断增加的数字,最近达到了七位数

main.py

from kivymd.app import MDApp
from kivy.lang import Builder
from kivy.core.window import Window
import socket

kv = """
Screen:
    MDLabel:
        text: ""
        id: txt
        pos_hint: {'center_x': 0.5, 'center_y': 0.85}
        halign: 'center'
    MDIconButton:
        id: socket_connect
        icon: "cellphone-off"
        pos_hint: {"center_x": .9, "center_y": .9}
        on_press:
            app.socket_connect()
    MDFillRoundFlatButton:
        pos_hint: {'center_x': 0.5, 'center_y': 0.27}
        width: dp(150)
        height: dp(150)
        md_bg_color: 0, 1, 0, 1
        on_press:
            app.send_direction(0, 1)
        on_release:
            app.send_direction(0, 0)
    MDFillRoundFlatButton:
        pos_hint: {'center_x': 0.5, 'center_y': 0.1}
        width: dp(150)
        height: dp(150)
        md_bg_color: 1, 0, 0, 1
        on_press:
            app.send_direction(2, 1)
        on_release:
            app.send_direction(0, 0)
    MDFillRoundFlatButton:
        pos_hint: {'center_x': 0.2, 'center_y': 0.1}
        width: dp(150)
        height: dp(150)
        md_bg_color: 0, 1, 1, 1
        on_press:
            app.send_direction(1, 1)
        on_release:
            app.send_direction(0, 0)
    MDFillRoundFlatButton:
        pos_hint: {'center_x': 0.8, 'center_y': 0.1}
        width: dp(150)
        height: dp(150)
        md_bg_color: 0, 1, 1, 1
        on_press:
            app.send_direction(3, 1)
        on_release:
            app.send_direction(0, 0)
"""


class Main(MDApp):
    data = {"direction": 0, "speed": 0, "autodrive": 0}
    Window.size = (1080 / 2, 1920 / 2)
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

    def socket_connect(self):
        button = self.root.ids.socket_connect
        button.icon = "cellphone_cog"
        label = self.root.ids.txt
        try:
            self.s.connect(("charlie.local", 5432))
            label.text = "Socket successfully connected!"
            button.icon = "cellphone-sound"
        except:
            label.text = "Socket connection unsuccessful."
            button.icon = "cellphone-off"
        return

    def send_direction(self, direction, speed):
        label = self.root.ids.txt
        message = "d: " + str(direction) + ", s: " + str(speed)
        label.text = message
        self.data["direction"] = direction
        self.data["speed"] = speed
        message = str(self.data["direction"])+str(self.data["speed"])+str(self.data["autodrive"])
        try:
            self.s.send(message.encode("utf-8"))
        except:
            label.text = "Socket not connected."

    def action(self):
        label = self.root.ids.txt
        label.text = "This text is displayed after pressing button"

    def build(self):
        return Builder.load_string(kv)


Main().run()
当我使用PyCharm在我的Windows PC上运行该应用程序时,它运行得非常好


任何帮助都将不胜感激

这是一个有趣的问题,但不知道为什么会发生。你在虚拟机中使用的是什么发行版?@Sarment我使用的是Ubuntu 20.04.2.0 LTS
from kivymd.app import MDApp
from kivy.lang import Builder
from kivy.core.window import Window
import socket

kv = """
Screen:
    MDLabel:
        text: ""
        id: txt
        pos_hint: {'center_x': 0.5, 'center_y': 0.85}
        halign: 'center'
    MDIconButton:
        id: socket_connect
        icon: "cellphone-off"
        pos_hint: {"center_x": .9, "center_y": .9}
        on_press:
            app.socket_connect()
    MDFillRoundFlatButton:
        pos_hint: {'center_x': 0.5, 'center_y': 0.27}
        width: dp(150)
        height: dp(150)
        md_bg_color: 0, 1, 0, 1
        on_press:
            app.send_direction(0, 1)
        on_release:
            app.send_direction(0, 0)
    MDFillRoundFlatButton:
        pos_hint: {'center_x': 0.5, 'center_y': 0.1}
        width: dp(150)
        height: dp(150)
        md_bg_color: 1, 0, 0, 1
        on_press:
            app.send_direction(2, 1)
        on_release:
            app.send_direction(0, 0)
    MDFillRoundFlatButton:
        pos_hint: {'center_x': 0.2, 'center_y': 0.1}
        width: dp(150)
        height: dp(150)
        md_bg_color: 0, 1, 1, 1
        on_press:
            app.send_direction(1, 1)
        on_release:
            app.send_direction(0, 0)
    MDFillRoundFlatButton:
        pos_hint: {'center_x': 0.8, 'center_y': 0.1}
        width: dp(150)
        height: dp(150)
        md_bg_color: 0, 1, 1, 1
        on_press:
            app.send_direction(3, 1)
        on_release:
            app.send_direction(0, 0)
"""


class Main(MDApp):
    data = {"direction": 0, "speed": 0, "autodrive": 0}
    Window.size = (1080 / 2, 1920 / 2)
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

    def socket_connect(self):
        button = self.root.ids.socket_connect
        button.icon = "cellphone_cog"
        label = self.root.ids.txt
        try:
            self.s.connect(("charlie.local", 5432))
            label.text = "Socket successfully connected!"
            button.icon = "cellphone-sound"
        except:
            label.text = "Socket connection unsuccessful."
            button.icon = "cellphone-off"
        return

    def send_direction(self, direction, speed):
        label = self.root.ids.txt
        message = "d: " + str(direction) + ", s: " + str(speed)
        label.text = message
        self.data["direction"] = direction
        self.data["speed"] = speed
        message = str(self.data["direction"])+str(self.data["speed"])+str(self.data["autodrive"])
        try:
            self.s.send(message.encode("utf-8"))
        except:
            label.text = "Socket not connected."

    def action(self):
        label = self.root.ids.txt
        label.text = "This text is displayed after pressing button"

    def build(self):
        return Builder.load_string(kv)


Main().run()