&quot'attributeError:部分初始化的模块' pytube'没有属性' YouTube' (最有可能是由于循环进口)。
这是代码:
import pytube as p
video_url = input("Enter the link: ")
youtube = p.YouTube(video_url)
filters = youtube.streams.filter(progressive=True, file_extension="mp4")
filters.get_highest_resolution().download("MyPath")
我尝试编写一个代码以下载YouTube视频。但这是一个错误的说法:
attributeError:部分初始化的模块'pytube'没有属性“ youtube”(最有可能是由于圆形导入引起的)
)
我什至从Internet复制了Pasted代码pytube,但没有任何作用。更令人沮丧的是,几个月前我执行它时的工作正常。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否注意到您的文件是如何命名的?
pytube.py
。这可能导致循环>循环导入
,因为Python试图导入
pytube.py
文件本身。我建议您阅读
this
和 /代码> ,第一个正是您的情况。因此,简短的答案是:
更改您的文件名!
当我说更改时,我的意思是您必须重命名您的文件,而不是创建新文件。
Did you notice how is your file named?
pytube.py
. This may have caused thecircular import
, since Python is trying toimport
thepytube.py
file itself.I would suggest you to read
this
andthis
, the first one is exactly your case.So the short answer is:
Change your file name!
And when I say change I mean that you have to rename your file, and not to create a new one.