Why do I receive these errors when I use pytube?

Asked By: Anonymous

My problem: When using the pytube package in the official Python IDLE, I receive a long list of errors. I am just playing around with a python YouTube video downloader and I’m not quite sure what is going on. I have a current python script that when ran, gives me this:

Traceback (most recent call last):
  File "C:UsersowenrDesktopPython Video Downloader.py", line 6, in <module>
    yt = YouTube(link)
  File "C:UsersowenrAppDataLocalProgramsPythonPython39libsite-packagespytube__main__.py", line 104, in __init__
    self.prefetch()
  File "C:UsersowenrAppDataLocalProgramsPythonPython39libsite-packagespytube__main__.py", line 221, in prefetch
    self.vid_info_raw = request.get(self.vid_info_url)
  File "C:UsersowenrAppDataLocalProgramsPythonPython39libsite-packagespytuberequest.py", line 42, in get
    return _execute_request(url, headers=extra_headers).read().decode("utf-8")
  File "C:UsersowenrAppDataLocalProgramsPythonPython39libsite-packagespytuberequest.py", line 26, in _execute_request
    return urlopen(request)  # nosec
  File "C:UsersowenrAppDataLocalProgramsPythonPython39liburllibrequest.py", line 214, in urlopen
    return opener.open(url, data, timeout)
  File "C:UsersowenrAppDataLocalProgramsPythonPython39liburllibrequest.py", line 523, in open
    response = meth(req, response)
  File "C:UsersowenrAppDataLocalProgramsPythonPython39liburllibrequest.py", line 632, in http_response
    response = self.parent.error(
  File "C:UsersowenrAppDataLocalProgramsPythonPython39liburllibrequest.py", line 555, in error
    result = self._call_chain(*args)
  File "C:UsersowenrAppDataLocalProgramsPythonPython39liburllibrequest.py", line 494, in _call_chain
    result = func(*args)
  File "C:UsersowenrAppDataLocalProgramsPythonPython39liburllibrequest.py", line 747, in http_error_302
    return self.parent.open(new, timeout=req.timeout)
  File "C:UsersowenrAppDataLocalProgramsPythonPython39liburllibrequest.py", line 523, in open
    response = meth(req, response)
  File "C:UsersowenrAppDataLocalProgramsPythonPython39liburllibrequest.py", line 632, in http_response
    response = self.parent.error(
  File "C:UsersowenrAppDataLocalProgramsPythonPython39liburllibrequest.py", line 561, in error
    return self._call_chain(*args)
  File "C:UsersowenrAppDataLocalProgramsPythonPython39liburllibrequest.py", line 494, in _call_chain
    result = func(*args)
  File "C:UsersowenrAppDataLocalProgramsPythonPython39liburllibrequest.py", line 641, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found 

The original code is,

from pytube import YouTube
import time
import sys
while True:
    link = input("Enter the link:")
    yt = YouTube(link)

    print("Information:")
    time.sleep(1.25)

    print("    Title: ", yt.title)
    print("    Number of views: ", yt.views)
    print("    Length of video: ", yt.views)
    print("    Ratings: ", yt.rating)
    time.sleep(1)
    
    yn = input("Is this correct? [Y / n]")
    if yn == "Y":
        print("Downloading...")
        stream = yt.streams.first()
        stream.download('C:\Users\owenr\Desktop\Python Videos')
        sys.exit("Status: Completed")
    if yn == "n":
        time.sleep(1)
        continue 

I receive very similar errors when I run this in the IDLE, not from the ‘.py’ file (As shown above).

>>> from pytube import YouTube
>>> yt = YouTube('https://www.youtube.com/watch?v=6TWJaFD6R2s')
Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    yt = YouTube('https://www.youtube.com/watch?v=6TWJaFD6R2s')
  File "C:UsersowenrAppDataLocalProgramsPythonPython39libsite-packagespytube__main__.py", line 104, in __init__
    self.prefetch()
  File "C:UsersowenrAppDataLocalProgramsPythonPython39libsite-packagespytube__main__.py", line 221, in prefetch
    self.vid_info_raw = request.get(self.vid_info_url)
  File "C:UsersowenrAppDataLocalProgramsPythonPython39libsite-packagespytuberequest.py", line 42, in get
    return _execute_request(url, headers=extra_headers).read().decode("utf-8")
  File "C:UsersowenrAppDataLocalProgramsPythonPython39libsite-packagespytuberequest.py", line 26, in _execute_request
    return urlopen(request)  # nosec
  File "C:UsersowenrAppDataLocalProgramsPythonPython39liburllibrequest.py", line 214, in urlopen
    return opener.open(url, data, timeout)
  File "C:UsersowenrAppDataLocalProgramsPythonPython39liburllibrequest.py", line 523, in open
    response = meth(req, response)
  File "C:UsersowenrAppDataLocalProgramsPythonPython39liburllibrequest.py", line 632, in http_response
    response = self.parent.error(
  File "C:UsersowenrAppDataLocalProgramsPythonPython39liburllibrequest.py", line 555, in error
    result = self._call_chain(*args)
  File "C:UsersowenrAppDataLocalProgramsPythonPython39liburllibrequest.py", line 494, in _call_chain
    result = func(*args)
  File "C:UsersowenrAppDataLocalProgramsPythonPython39liburllibrequest.py", line 747, in http_error_302
    return self.parent.open(new, timeout=req.timeout)
  File "C:UsersowenrAppDataLocalProgramsPythonPython39liburllibrequest.py", line 523, in open
    response = meth(req, response)
  File "C:UsersowenrAppDataLocalProgramsPythonPython39liburllibrequest.py", line 632, in http_response
    response = self.parent.error(
  File "C:UsersowenrAppDataLocalProgramsPythonPython39liburllibrequest.py", line 561, in error
    return self._call_chain(*args)
  File "C:UsersowenrAppDataLocalProgramsPythonPython39liburllibrequest.py", line 494, in _call_chain
    result = func(*args)
  File "C:UsersowenrAppDataLocalProgramsPythonPython39liburllibrequest.py", line 641, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found

The link used in this example is entirely arbitrary. As you can see, the errors only show after

yt = YouTube('https://www.youtube.com/watch?v=6TWJaFD6R2s')

If somebody could help me figure out what is going on here and how to fix it, that would be much appreciated.


Solution

Answered By: Anonymous

This appears to be a problem with the PyTube library. There is an issue about it here: https://github.com/pytube/pytube/issues/495

It looks like it has been recently fixed (as of 9 hours ago) and a new release was issued 27 minutes ago.

I’d suggest upgrading by calling pip install pytube --upgrade and trying your code again.

techinplanet staff

techinplanet staff


Windows 10 Kaufen Windows 10 Pro Office 2019 Kaufen Office 365 Lizenz Windows 10 Home Lizenz Office 2019 Home Business Kaufen windows office 365 satın al follower kaufen instagram follower kaufen porno