生成kivy应用时出错:ModuleNotFoundError:没有名为“ typing_extensions”的模块

问题描述

我正在尝试为Android打包Kivy应用。这是我要编译的代码:

div{
  padding:10px;
  border: 1px solid red;
}

#div-d{
  margin-left:-32px;
  margin-right:-32px;
}

这是完整的错误:

from pytube import YouTube

import kivy
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.gridlayout import GridLayout
from kivy.uix.textinput import TextInput
from kivy.uix.button import Button


def download(url):

    try: 
        yt = YouTube(url)
        vids = yt.streams.order_by('resolution')

        #formVids = []

        if len(vids) > 0:

            print("Downloading...")
            vids.first().download()
            print("Video Downloaded")

        else:
            print("Couldn't download that video")

    except Exception as e:
        print("Failed to download video: ",e)


class MyGrid(GridLayout):
    def __init__(self,**kwargs):
        super(MyGrid,self).__init__(**kwargs)
        self.cols = 1

        self.inside = GridLayout()
        self.inside.cols = 2

        self.add_widget(Label(text="Note: Downloading Youtube videos is against Youtubes terms of service. \nDownload videos only if the creator is okay with it. E.g.,a lot of gaming channels \nare okay with fans downloading content in order to make compilations. \nAlso not that downloading copyrighted content (songs,movies,etc) is a criminal offense.",halign = "center"))
        self.add_widget(Label(text="Paste the url of the video in the whitespace below"))
        self.name = TextInput(multiline=False)
        self.add_widget(self.name)

        self.submit = Button(text="Download",font_size=60)
        self.submit.bind(on_press=self.pressed)
        self.add_widget(self.submit)

    def pressed(self,instance):
        url = self.name.text
        download(url)
        print(url)

class MyApp(App):
    def build(self):
        return MyGrid()


if __name__ == "__main__":
    MyApp().run()

我尝试将'typing_extensions'添加到Android kivy bootstrap done. __name__ is __main__ 09-01 12:07:54.268 17974 18054 I python : AND: Ran string 09-01 12:07:54.268 17974 18054 I python : Run user program,change dir and execute entrypoint 09-01 12:07:54.444 17974 18054 I python : Traceback (most recent call last): 09-01 12:07:54.444 17974 18054 I python : File "/home/joshua/youtubeDownloader/.buildozer/android/app/main.py",line 1,in <module> 09-01 12:07:54.445 17974 18054 I python : File "/home/joshua/youtubeDownloader/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/youtubeDownloader/pytube/__init__.py",line 13,in <module> 09-01 12:07:54.445 17974 18054 I python : File "/home/joshua/youtubeDownloader/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/youtubeDownloader/pytube/streams.py",line 22,in <module> 09-01 12:07:54.445 17974 18054 I python : File "/home/joshua/youtubeDownloader/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/youtubeDownloader/pytube/monostate.py",line 4,in <module> 09-01 12:07:54.445 17974 18054 I python : ModuleNotFoundError: No module named 'typing_extensions' 09-01 12:07:54.445 17974 18054 I python : Python for android ended. 说明符旁边的buildozer.spec文件中,但这也不起作用。对于为什么发生这种情况和/或如何解决它的任何帮助,将不胜感激!

解决方法

我不太确定我的答案,但是

也许您可以尝试在typing-extensions文件中放置typing_extensions而不是builder.spec

为此将_替换为-

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...