Pytube: ImportError: cannot import name Youtube

Created on 26 Sep 2016  路  20Comments  路  Source: pytube/pytube

Did a pip install pytube, tried import Youtube with
from pytube import Youtube
uninstalled and did a

git clone https://github.com/nficano/pytube.git && cd pytube
setup.py build
sudo setup.py install

still cannot import Youtube

However I did a dir(pytube) and see 'Youtube' there
I'm not sure why I cant import it

Most helpful comment

I have the same ImportError. The import statement from pytube import YouTube does not work. Can not resolve module.

All 20 comments

from pytube import YouTube

Note the case on "YouTube" ;)

oh wow, ty

from pytube import YouTube
yt = YouTube('https://www.youtube.com/watch?v=47L9HXwxiIg&t=28s')
stream = yt.streams.first()
stream.download('C:/')

stream.download()

from pytube import YouTube

ImportError: cannot import name 'YouTube' from 'pytube'

I have the same ImportError. The import statement from pytube import YouTube does not work. Can not resolve module.

importError: cannot import name 'YouTube' from partially initialized module 'pytube' (most likely due to a circular import)

I am getting the same kind import error. anyone can help to resolve the same ?

ImportError: cannot import name 'YouTube' from partially initialized module 'pytube' (most likely due to a circular import)

help me out!!

Try using https://github.com/ytdl-org/youtube-dl. this worked for me.

@venkatkumar1810 @NikunjVadsak

The circular import error happens because you named your script pytube.py. Python prioritises modules in the working directory so you are trying to import your script pytube recursively.

Renaming the file to something else will fix this.

@venkatkumar1810 @NikunjVadsak

The circular import error happens because you named your script pytube.py. Python prioritises modules in the working directory so you are trying to import your script pytube recursively.

Renaming the file to something else will fix this.

i renamed the name from my script,and the error "cannot import name 'YouTube' " still in my terminal.

@Jonas010 Could you show the exact import statement you used?

I have the exact same problem as @Jonas010.
image

image

That's really strange!

If you run the same program from the terminal do you get the same error? Could be a VScode issue.

Also, make sure you have pytube3 installed instead of pytube.Maybe VSCode installed pytube instead of pytube3. It's still imported with pytube but the pip package is called pytube3.

Try pip list to see what packages you have installed.

I have installed pytube3 so that shouldn't be the problem. How can I run the script in the terminal? Can't find how to do it on google.

I'm not very familiar with Windows but you should be able to:

  • hit Win+R
  • type cmd
  • When your in the prompt run either python path\to\script.py or python3 path\to\script.py

Let me know if that doesn't work

when using the command prompt i get the same message when using python path\to\script.py or python3 path\to\script.py

image

Damn... I really have no idea at this point, sorry.

As a last resort, you could try reinstalling pytube with python3 -m pip uninstall --user pytube3 then python3 -m pip install --user pytube3

already tried that. you were my last hope hahaha.

Maybe open your own issue for this, someone more experienced than me might know what's wrong. Sorry I couldn't help, best of luck with your programming!

@exciteabletom I have found the problem, the "T" in Youtube has to be a capital. So it has to be "YouTube" and not "Youtube". Thanks a lot for your help!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stephanemombuleau picture stephanemombuleau  路  19Comments

kpister picture kpister  路  23Comments

MrspiLLnyK picture MrspiLLnyK  路  20Comments

stdedos picture stdedos  路  24Comments

twwwy picture twwwy  路  54Comments