pytube: import error

I am getting this error

from pytube.compat import quote

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 18
  • Comments: 17

Most upvoted comments

if u r using python3.8 , try download pytube3 instead of pytube. it works for me.

https://pypi.org/project/pytube3/

I temporarily solved this problem by edit the file .../lib/python3.6/site-packages/pytube/compat.py, add these lines under elif PY3:

elif PY3:
    from urllib import request
    from urllib.parse import quote, urlencode, parse_qsl, unquote
    from urllib.request import urlopen

pip install pytube3

It works bro. Thanks

I am also getting this error: Traceback (most recent call last): File “ytPlaylistDL.py”, line 11, in <module> from pytube import YouTube File “…\Python\Python37\lib\site-packages\pytube_init_.py”, line 16, in <module> from pytube.streams import Stream File “…\Python\Python37\lib\site-packages\pytube\streams.py”, line 17, in <module> from pytube import extract File “…\Python\Python37\lib\site-packages\pytube\extract.py”, line 7, in <module> from pytube.compat import quote ImportError: cannot import name ‘quote’ from ‘pytube.compat’ (…\Python\Python37\lib\site-packages\pytube\compat.py)

I temporarily solved this problem by edit the file .../lib/python3.6/site-packages/pytube/compat.py, add these lines under elif PY3:

elif PY3:
    from urllib import request
    from urllib.parse import quote, urlencode, parse_qsl, unquote
    from urllib.request import urlopen

Thanks, it worked for me, you’re a legend.

I was also getting same error

ImportError: cannot import ‘quote’ from ‘pytube.compat’

But it works fine after I install pytube3.

Thank you @leo860607 for the solution. Thank you @muhammedfurkan for opening this issue

Thank you 😃

Nope, python 3.8 and pytube3 and:

Traceback (most recent call last): File …/Python/text/tube.py", line 1, in from pytube import YouTube File …\AppData\Roaming\Python\Python38\site-packages\pytube__init__.py", line 16, in from pytube.streams import Stream File …\AppData\Roaming\Python\Python38\site-packages\pytube\streams.py", line 17, in from pytube import extract File …\AppData\Roaming\Python\Python38\site-packages\pytube\extract.py", line 7, in from pytube.compat import quote ImportError: cannot import name ‘quote’ from ‘pytube.compat’

Did you remove pytube before downloaded pytube3 ? In my pytube3 files, qute import is in line 9 not 7 in the extract.py