Closed JMIdeaMaker closed 7 years ago
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:/')
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 scriptpytube
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.
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:
Win+R
cmd
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
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!
from pytube import YouTube
YouTube('https://youtu.be/2lAe1cqCOXo').streams.first().download()
yt = YouTube('http://youtube.com/watch?v=2lAe1cqCOXo')
yt.streams
filter(progressive=True, file_extension='mp4')
order_by('resolution')
desc()
first()
download()
Traceback (most recent call last):
File "C:\Users\ZeinabBahaa\Desktop\pytube.py", line 1, in <module>
from pytube import YouTube
File "C:\Users\ZeinabBahaa\Desktop\pytube.py", line 1, in <module>
from pytube import YouTube
ImportError: cannot import name 'YouTube' from partially initialized module 'pyt
ube' (most likely due to a circular import) (C:\Users\ZeinabBahaa\Desktop\pytu
be.py)
Rename your file. Its called ‘pytube’ so it conflicts with the library name which is also ‘pytube’
On Aug 4, 2021 at 6:19 am, <ZeinabBahaa @.***)> wrote:
from pytube import YouTube YouTube('https://youtu.be/2lAe1cqCOXo').streams.first().download() yt = YouTube('http://youtube.com/watch?v=2lAe1cqCOXo') yt.streams filter(progressive=True, file_extension='mp4') order_by('resolution') desc() first() download()
Traceback (most recent call last): File "C:\Users\ZeinabBahaa\Desktop\pytube.py", line 1, in
from pytube import YouTube File "C:\Users\ZeinabBahaa\Desktop\pytube.py", line 1, in from pytube import YouTube ImportError: cannot import name 'YouTube' from partially initialized module 'pyt ube' (most likely due to a circular import) (C:\Users\ZeinabBahaa\Desktop\pytu be.py) — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub (https://github.com/pytube/pytube/issues/111#issuecomment-892204002), or unsubscribe (https://github.com/notifications/unsubscribe-auth/ANDX73YLHKVSEMD53NVQU6DT3BTP5ANCNFSM4CQ3TE6Q). Triage notifications on the go with GitHub Mobile for iOS (https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675) or Android (https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email).
What helped me was renaming my files from "pytube.py" to "downloader.py"
Did a pip install pytube, tried import Youtube with
from pytube import Youtube
uninstalled and did astill cannot import Youtube
However I did a dir(pytube) and see 'Youtube' there I'm not sure why I cant import it