我正在尝试为android打包一个Kivy应用程序。这是我试图编译的代码:
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()
这是全部错误:
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.
我尝试在requirements
说明符旁边的buildozer.spec文件中添加'typing_extensions',但也没有成功。如果您能提供任何帮助,了解发生这种情况的原因和/或如何解决,我们将不胜感激
尝试使用以下方法重新安装typing_extensions软件包:
我不确定我的答案,但是
也许您可以尝试将
typing-extensions
而不是typing_extensions
放在builder.spec
文件中将
_
替换为-
相关问题 更多 >
编程相关推荐