ImportError: No module named youtube_dl

Viewed 23114
from __future__ import unicode_literals
import youtube_dl

print('Hello, please insert the url of the video that you want to download.')

downloadUrl = input()

ydl_opts = {}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
        ydl.download([downloadUrl])

Hey, um, the program overall seems to be working just fine when it opens with the cmd, but when I try to run it with F5 in the IDLE, it crashes with the error: ImportError: No module named youtube_dl. I have it installed and tried re-installing it aswell. This particular program works fine, but trying to write anything else using this module brings this error up even in the cmd window.

3 Answers

Reinstalling it with the following pip command worked for me.

CMD: pip install --upgrade youtube-dl

Jupyter Notebook: !pip install --upgrade youtube-dl

What worked for me was

pip3 install --upgrade youtube-dl

check if those packages are present in your local ie C:\Users\yourname\AppData\Roaming\Python\Python37\site-packages

  1. youtube_dl
  2. youtube_dl-2019.10.16.dist-info
  3. pafy
  4. pafy-0.5.4.dist-info

else

pip install pafy

then copy paste these files from C:\Program Files\Python37\Lib\site-packages to the local

Related