pytube: ImportError: cannot import name 'quote' from 'pytube.compat'

When I try to run

from pytube import Youtube

It crashes and emits this error

ImportError: cannot import name 'quote' from 'pytube.compat'

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 24
  • Comments: 19

Most upvoted comments

pip install pytube3 worked for me

For Linux -> install library:

pip uninstall pytube
pip install pytube3

-> inside:

pip/pytube/extract.py

-> find:

parse_qs(formats[i]["cipher"]) for i, data in enumerate(formats)

-> and change it to:

parse_qs(formats[i]["signatureCipher"]) for i, data in enumerate(formats)

-> how to use pytube:

from pytube import YouTube
import os
def downloadYoutube(vid_url, path):
    yt = YouTube(vid_url)
    yt = yt.streams.filter(progressive=True, file_extension='mp4').order_by('resolution').desc().first()
    if not os.path.exists(path):
        os.makedirs(path)
    yt.download(path)

url = input('Input url:\n')
path = input('Path to store file:\n')
downloadYoutube(url, path)

try using pip install pytube3 Note: make sure to uninstall the formal version of pytube then reinstall pytube3

it will work out

try using pip install pytube3 Note: make sure to uninstall the formal version of pytube then reinstall pytube3 it will work out

try using pip install pytube3 Note: make sure to uninstall the formal version of pytube then reinstall pytube3 it will work out

It is still showing error

from pytube import YouTube
YouTube("http://youtube.com/watch?v=9bZkp7q19f0").streams.first()

Traceback (most recent call last): File “C:/Users/Lenovo/Desktop/Folder/Projects/python/YTDownloder/downloder.py”, line 1, in from pytube import YouTube ImportError: cannot import name ‘YouTube’

try this: pytube.YouTube(“http://youtube.com/watch?v=9bZkp7q19f0”).streams.first()

Yes you can try pip install pytube3, it also worked for me

  1. Uninstall any previous pytube versions (either pytube/pytube3)

  2. Perform a clean start in conda/python environment as “pip install pytube3”

  3. Go to the package location of pytube and look for file pytube/extract.py

  4. Look for the line “parse_qs(formats[i][“cipher”]) for i, data in enumerate(formats)”

  5. Change “cipher” —> “signatureCipher”

It will eventually work. I am using python version 3.7.7

pip install pytube3 worked for me

It good working…

Hello I face the same problem with pytube I tried to uninstall it but the compiler give me the following any pip uninstall help please

try. pip install pytube3

@Dhruv200329, have you uninstalled the previous version of pytube on your machine?, if not you’ll keep getting the error message, after this re-install pytube3 and it will work, cheers.