Installing YouTube-DL on Windows Subsystem for Linux (WSL)

Please read my previous post on how to enable Windows Subsystem for Linux (WSL) on Windows 10.  You must have the Windows 10 anniversary update installed since WSL is not available on the original Windows 10.

Youtube-dl is an awesome downloader for multimedia from the internet using a simple command line.  You can encode the video into a different format as well (namely FLV and MP4).

Since Windows System for Linux doesn’t automatically install Python which is required for Youtub-dl to work correctly, you need to first install Python.  You can install either Python 2.7x or Python 3.x.  I installed Python 2.7x since most libraries are more compatible with it.  To install Python 2.7x, open up your Ubuntu Bash window, and type in this command:

sudo apt-get install python

If you are adventurous and want to try Python 3, then use this command:

sudo apt-get install python3

In the past when I tried having both versions, there are conflicts when trying to run Python codes. So I just pick one version and stick with it. I recommend using 2.7x for stability and comparability. Eventually Python 3 will be the best version but maybe give it a couple more years.

There are many ways to install youtube-dl, here are the 2 common ways:

Using apt-get
Open up your Ubuntu Bash window, and type in this command:

sudo apt-get install youtube-dl

After the installation is done, run an update

sudo youtube-dl -U

Using Pip
First you have to install Pip

sudo apt-get install python-pip python-dev build-essential 
sudo pip install --upgrade pip 
sudo pip install --upgrade virtualenv 

Now you can install youtube-dl with pip using this command:

sudo pip install youtube_dl

Then upgrade with Pip

sudo pip install --upgrade youtube_dl

If you try to do a video download (Master of the House song from Le Miserable) from youtube, you’ll get a bunch of errors.

sudo youtube-dl -o LeMiserableMasterHouse.MP4 ""

From searching the web, I found that we need to do a bunch of permission settings to get the downloader to not error out due to things like Protocol error and such. Use this command first:

sudo curl -L -o /usr/local/bin/youtube-dl

Then set permissions:

sudo chmod a+rx /usr/local/bin/youtube-dl

Now you shouldn’t have problem downloading videos from youtube. The video is downloaded to the directory where you issues the youteb-dl command. You can supply the extension of the file to be .FLV or .MP4 when downloading.

For more details on the commands and options for youtube-dl, please visit this URL:

Enjoy downloading YouTube videos!

2 thoughts on “Installing YouTube-DL on Windows Subsystem for Linux (WSL)

  1. Hi Patrick! I’ve installed ubuntu 18.04 from the windows store. Also run sudo apt install youtube-dl. But if I attemp to use it, I get

    /usr/bin/env: ‘python’: No such file or directory

    I don’t know what to do. Could you please help me with this?

    • I should probably add to the post that Python should be installed since WSL doesn’t install python by default. You can install Python 2.7 using this command in the console:

      sudo apt-get install python

      You could alternatively install Python 3.x using this command:

      sudo apt-get install python3

      I would use Python 2.7 though since it has more comparability with older Python codes.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.