pytube: ImportError: cannot import name Youtube
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
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 23
Commits related to this issue
- Use "from pytube import YouTube" REF:https://github.com/nficano/pytube/issues/111#issuecomment-249984747 — committed to RandyMcMillan/smd by RandyMcMillan 4 years ago
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 ?
@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 scriptpytube
recursively.Renaming the file to something else will fix this.
from pytube import YouTube
Note the case on “YouTube” 😉
Rename your file. Its called ‘pytube’ so it conflicts with the library name which is also ‘pytube’
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!
from pytube import YouTube yt = YouTube(‘https://www.youtube.com/watch?v=47L9HXwxiIg&t=28s’) stream = yt.streams.first() stream.download(‘C:/’)
stream.download()
ImportError: cannot import name ‘YouTube’ from ‘pytube’
oh wow, ty