Skip to main content

Python 3 library for downloading YouTube Videos.

Project description

pytube logo


Actively soliciting contributers!

Have ideas for how pytube can be improved? Feel free to open an issue or a pull request!


pytube is a very serious, lightweight, dependency-free Python library (and command-line utility) for downloading YouTube Videos.


Detailed documentation about how to use the library can be found on This is recommended for most use cases. If you just want to quickly download a single video, the quickstart guide below might be what you're looking for.


YouTube is the most popular video-sharing platform in the world and as a hacker you may encounter a situation where you want to script something to download videos. For this I present to you pytube.

pytube is a lightweight library written in Python. It has no third party dependencies and aims to be highly reliable.

pytube also makes pipelining easy, allowing you to specify callback functions for different download events, such as on progress or on complete.

Finally pytube also includes a command-line utility, allowing you to quickly download videos right from terminal.


  • Support for both progressive & DASH streams
  • Support for downloading complete playlist
  • Easily register on_download_progress & on_download_complete callbacks
  • Command-line interfaced included
  • Caption track support
  • Outputs caption tracks to .srt format (SubRip Subtitle)
  • Ability to capture thumbnail URL
  • Extensively documented source code
  • No third-party dependencies


This guide is only meant to cover the most basic usage of the library. For more detailed information, please refer to


Pytube requires an installation of python 3.6 or greater, as well as pip. Pip is typically bundled with python installations, and you can find options for how to install python at

To install from pypi with pip:

$ python -m pip install pytube

Sometime, the pypi release becomes slightly outdated. To install from the source with pip:

$ python -m pip install git+

Using pytube in a python script

To download a video using the library in a script, you'll need to first import the YouTube class from the library, and pass it an argument of the video url. From there, you can access the streams and download them.

 >>> from pytube import YouTube
 >>> YouTube('').streams.first().download()
 >>> yt = YouTube('')
 >>> yt.streams
  ... .filter(progressive=True, file_extension='mp4')
  ... .order_by('resolution')
  ... .desc()
  ... .first()
  ... .download()

Using the command-line interface

Using the CLI is extremely straightforward as well. To download a video at the highest progressive quality, you can use the following command:

$ pytube

You can also do the same for a playlist:

$ pytube

Project details

Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytube-10.8.0.tar.gz (56.7 kB view hashes)

Uploaded Source

Built Distribution

pytube-10.8.0-py3-none-any.whl (45.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page