3

I am trying Pafy library but seem to have encountered a problem. This is my code:

a = pafy.new("http://www.youtube.com/watch?v=W2AF8jH84o0")

And this is the error I am getting:

https://i.stack.imgur.com/NRKZg.png

2 Answers2

3

Youtube-DL must be downloaded as well since Pafy uses it as a dependancy.

You can use Pip: sudo -H pip install --upgrade youtube-dl

On a Mac, you can download it using homebrew instead: brew install youtube-dl

On Unix like machines (Mac, Linux), you can use curl:

sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl

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

If Youtube-DL isn't found on your machine, Pafy usually falls back to it's internal mechanisms, which are "not as well mantained." If you really can't download Youtube-DL, you can try to use Pafy's own internal backend (not recommended) by adding the line:

pafy.BACK_END = "internal"

The recommended method is Youtube-DL

Saransh Malik
  • 726
  • 1
  • 4
  • 16
0

Before anything, I imagine you imported the library with:

import pafy

a = pafy.new("http://www.youtube.com/watch?v=W2AF8jH84o0")
Kaustubh Khare
  • 3,280
  • 2
  • 32
  • 48