[Fixed] KeyError: 'streamingData' in a YouTube downloader – Python

Ali Hasan
llama-cpp-python python-3.x pytube

Quick Fix: Upgrade pytube to version 15.0.0 using pip:

pip install pytube==15.0.0

The Problem:

When using the pytube library to download YouTube videos, a KeyError: 'streamingData' is encountered while trying to access the video’s stream information to download the highest resolution version. This error occurs despite the code being seemingly correct.

The Solutions:

Solution 1: Upgrade pytube

Upgrading the pytube package to version 15.0.0 solves the issue by updating its dependency on the “pafy” package, which addresses the “streamingData” KeyError. To upgrade, use the following pip command:

pip install --upgrade pytube

Solution 2: Authenticate using OAuth

To resolve the ‘streamingData’ KeyError, the solution lies in using OAuth authentication to access the YouTube API.
Update the code as follows:

yt = pytube.YouTube(videolink, use_oauth=True, allow_oauth_cache=True)

This will initiate the OAuth authentication process, requiring you to sign in to your Google account the first time. Afterward, the ‘streamingData’ will become accessible, enabling you to download videos successfully.

Solution 3: Downgrade pytube or use yt_dlp

This error can occur due to an outdated version of pytube. To resolve this issue, downgrade pytube to an earlier version. Alternatively, you can install yt_dlp using pip install yt_dlp. Here’s a code example using yt_dlp:

import yt_dlp

link = "(any YouTube link)"

ydl_opts = {
    'format': 'best',

with yt_dlp.YoutubeDL(ydl_opts) as ydl:

print("downloaded", link)

Solution 4: Upgrade pyTube

The KeyError “streamingData” can be resolved by upgrading the pyTube library. Run the following command in your terminal or command prompt:

pip install --upgrade pytube


What’s the purpose of upgrading pytube?

Upgrading pytube to version 15.0.0 can resolve the streamingData KeyError.

How to fix the error with another YouTube downloader?

yt_dlp can be used to download YouTube videos without encountering the streamingData KeyError.

Video Explanation:

The following video, titled "How to Resolve KEY ERRORS in Python! - YouTube", provides additional insights and in-depth exploration related to the topics discussed in this post.

Play video

Walking tours Oakland Chinatown · Python Programming Tutorial #18 - Try and Except (Python Error Handling) · KeyError Pandas: How To Fix · When ...