pythonembedyoutube-dl

How to Embed Youtube-dl in a Python Script


I'm trying to write a Python Script that downloads videos from youtube, and to do this I'm trying to use youtube-dl. However, when I insert the code in my python script on their github page that is supposed to embed the code

from __future__ import unicode_literals
import youtube_dl

ydl_opts = {}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
    ydl.download(['https://www.youtube.com/watch?v=BaW_jenozKc'])

my terminal spits out 'ImportError: No module named 'youtube_dl'

What does this mean and how do I allow my script to access the youtube-dl module? I'm guessing this has something to do with locating the original path I downloaded youtube_dl to.


Solution

  • You need to install the module first.

    You can do this by using the command pip install youtube_dl in your terminal.

    If pip in not installed, follow these guidelines: https://pip.pypa.io/en/stable/installing/