Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pytube : urllib.error.HTTPError: HTTP Error 410: Gone

I've been getting this error on several programs for now. I've tried upgrading pytube, reinstalling it, tried some fixes, changed URLs and code, but nothing seems to work.

from pytube import YouTube

#ask for the link from user
link = input("Enter the link of YouTube video you want to download:  ")
yt = YouTube(link)

#Showing details
print("Title: ",yt.title)
print("Number of views: ",yt.views)
print("Length of video: ",yt.length)
print("Rating of video: ",yt.rating)
#Getting the highest resolution possible
ys = yt.streams.get_highest_resolution()

#Starting download
print("Downloading...")
ys.download()
print("Download completed!!")

and this is the error code:

  File "C:\Users\Madjid\PycharmProjects\pythonProject\app2.py", line 6, in <module>
    yt = YouTube(link)
  File "C:\Users\Madjid\PycharmProjects\pythonProject\venv\lib\site-packages\pytube\__main__.py", line 91, in __init__
    self.prefetch()
  File "C:\Users\Madjid\PycharmProjects\pythonProject\venv\lib\site-packages\pytube\__main__.py", line 181, in prefetch
    self.vid_info_raw = request.get(self.vid_info_url)
  File "C:\Users\Madjid\PycharmProjects\pythonProject\venv\lib\site-packages\pytube\request.py", line 36, in get
    return _execute_request(url).read().decode("utf-8")
  File "C:\Users\Madjid\PycharmProjects\pythonProject\venv\lib\site-packages\pytube\request.py", line 24, in _execute_request
    return urlopen(request)  # nosec
  File "E:\Python\lib\urllib\request.py", line 214, in urlopen
    return opener.open(url, data, timeout)
  File "E:\Python\lib\urllib\request.py", line 523, in open
    response = meth(req, response)
  File "E:\Python\lib\urllib\request.py", line 632, in http_response
    response = self.parent.error(
  File "E:\Python\lib\urllib\request.py", line 555, in error
    result = self._call_chain(*args)
  File "E:\Python\lib\urllib\request.py", line 494, in _call_chain
    result = func(*args)
  File "E:\Python\lib\urllib\request.py", line 747, in http_error_302
    return self.parent.open(new, timeout=req.timeout)
  File "E:\Python\lib\urllib\request.py", line 523, in open
    response = meth(req, response)
  File "E:\Python\lib\urllib\request.py", line 632, in http_response
    response = self.parent.error(
  File "E:\Python\lib\urllib\request.py", line 561, in error
    return self._call_chain(*args)
  File "E:\Python\lib\urllib\request.py", line 494, in _call_chain
    result = func(*args)
  File "E:\Python\lib\urllib\request.py", line 641, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 410: Gone
like image 660
Madjid Avatar asked Aug 06 '21 10:08

Madjid


4 Answers

Try to upgrade, there is a fix in version 11.0.0:

python -m pip install --upgrade pytube
like image 93
mitchus Avatar answered Oct 21 '22 06:10

mitchus


If you haven't already, install Git on your PC: https://git-scm.com/download/win

Then open the command window as admin and install this patch:

python -m pip install git+https://github.com/Zeecka/pytube@fix_1060
like image 22
Sciveo Avatar answered Oct 21 '22 05:10

Sciveo


I build mine from start to bottom, and ran into to same issue here are the code and steps.

Code:

from pytube import YouTube
from sys import argv



link = argv[1]
yt = YouTube(link)



yd = yt.streams.get_highest_resolution()

yd.download(r'C:/Users/adam/OneDrive/Desktop/video')

got error:

urllib.error.HTTPError: HTTP Error 410: Gone

STEPS:

  1. python -m pip install --upgrade pytube

  2. python3 -m pip install git+https://github.com/pytube/pytube

  3. Ran as ADMIN.

worked fine!

like image 1
Adi S Avatar answered Oct 21 '22 05:10

Adi S


This is a bug of the pytube version. You might install an older version of it. Upgrade pytube to 11+ will resolve the issue.

  • Open the terminal and execute the following command to upgrade the version

    pip install --upgrade pytube
    

enter image description here

https://github.com/pytube/pytube/issues/1243

like image 1
Codemaker Avatar answered Oct 21 '22 06:10

Codemaker