【问题标题】:Exception in Tkinter callback when trying to use pytube尝试使用 pytube 时 Tkinter 回调中的异常
【发布时间】:2021-06-23 10:47:37
【问题描述】:

在尝试使用我制作的视频下载器时,我不断收到错误说明。 我已经查看了很多其他问题,试图找到解决方案,但几乎就像我是唯一一个遇到这个问题的人

附上错误和我的代码

   import pytube
   import tkinter
   from tkinter import *
   from pytube import YouTube
   
   root = Tk()
   root.geometry('500x300')
   root.resizable(0,0)
   root.title("DataFlair-youtube video downloader")
   
   
   Label(root,text = 'Youtube Video Downloader', font ='arial 20 bold').pack()
   
   link = StringVar()
   
   Label(root, text = 'Paste Link Here:', font = 'arial 15 bold').place(x= 160 , y = 60)
   link_enter = Entry(root, width = 70,textvariable = link).place(x = 32, y = 90)
   
   
   def Downloader():
        
       url =YouTube(str(link.get()))
       video = url.streams.first()
       video.download()
       Label(root, text = 'DOWNLOADED', font = 'arial 15').place(x= 180 , y = 210)  
   
   
   Button(root,text = 'DOWNLOAD', font = 'arial 15 bold' ,bg = 'pale violet red', padx = 2, command = Downloader).place(x=180 ,y = 150)
   
   
   
   root.mainloop()

    Exception in Tkinter callback Traceback (most recent call last):   File "C:\Users\Owner\AppData\Local\Programs\Python\Python39\lib\tkinter\__init__.py", line 1884, in __call__
        return self.func(*args)   File "c:\Users\Owner\Downloads\youtube_download.py", line 22, in Downloader
        url =YouTube(str(link.get()))   File "C:\Users\Owner\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\__main__.py", line 91, in __init__
        self.prefetch()   File "C:\Users\Owner\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\__main__.py", line 181, in prefetch
        self.vid_info_raw = request.get(self.vid_info_url)   File "C:\Users\Owner\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\request.py", line 36, in get
        return _execute_request(url).read().decode("utf-8")   File "C:\Users\Owner\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\request.py", line 24, in _execute_request
        return urlopen(request)  # nosec   File "C:\Users\Owner\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 214, in urlopen
        return opener.open(url, data, timeout)   File "C:\Users\Owner\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 523, in open
        response = meth(req, response)   File "C:\Users\Owner\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 632, in http_response
        response = self.parent.error(   File "C:\Users\Owner\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 555, in error
        result = self._call_chain(*args)   File "C:\Users\Owner\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 494, in _call_chain
        result = func(*args)   File "C:\Users\Owner\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 747, in http_error_302
        return self.parent.open(new, timeout=req.timeout)   File "C:\Users\Owner\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 523, in open
        response = meth(req, response)   File "C:\Users\Owner\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 632, in http_response
        response = self.parent.error(   File "C:\Users\Owner\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 561, in error
        return self._call_chain(*args)   File "C:\Users\Owner\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 494, in _call_chain
        result = func(*args)   File "C:\Users\Owner\AppData\Local\Programs\Python\Python39\lib\urllib\request.py", line 641, in http_error_default
        raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 404: Not Found

【问题讨论】:

标签: python python-3.x tkinter pytube


【解决方案1】:

其他人也面临与pytube 相同的问题。您可能想在此处查看解决方案。 Stackoverflow Question

【讨论】:

    【解决方案2】:

    当我使用Pytube 10.8.3 运行时出现错误404,但它适用于最新的10.8.5

    YouTube 有时会在页面上进行更改,PyTube 可能也需要更新。

    【讨论】:

      猜你喜欢
      • 2020-09-16
      • 1970-01-01
      • 1970-01-01
      • 2012-09-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-24
      相关资源
      最近更新 更多