微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决生成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

为此将_替换为-

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。