Pytube common error while downloading video PYTHON


I am trying to download a YouTube video using pytube but i get the error bellow, this error has been mentioned in stack overflow many times but almost all of them are outdated.

This and this questions are having the same problems and are left unanswered.

This question has been answered here and here but the answered appears to be outdated and so it does not work anymore.


Traceback (most recent call last):
  File "", line 60, in <module>
  File "", line 22, in DownloadVideo
    video_stream = yt.streams.get_highest_resolution()
  File "", line 296, in streams
    return StreamQuery(self.fmt_streams)
  File "", line 181, in fmt_streams
    extract.apply_signature(stream_manifest, self.vid_info, self.js)
  File "", line 409, in apply_signature
    cipher = Cipher(js=js)
  File "", line 43, in __init__
    self.throttling_plan = get_throttling_plan(js)
  File "", line 411, in get_throttling_plan
    transform_plan_raw = find_object_from_startpoint(raw_code, match.span()[1] - 1)
AttributeError: 'NoneType' object has no attribute 'span'

Process finished with exit code 1


def DownloadVideo(ID):
    yt = YouTube(f'{ID}')
    video_stream = yt.streams.get_highest_resolution()'OutPut', filename=f'{ID}.mp4')
Asked By: CoolGuy



This error might because of a modification in youtube cipher algorithm or something else, you can still try with pytube but you will be better with an alternative library like the way more used and updated yt-dlp with pip install yt-dlp

still you can try to install the last version with pip install --upgrade pytube

Answered By: Saxtheowl
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.