iT邦幫忙

1

[Python] pytube 抓 youtube影片 錯誤

  • 分享至 

  • xImage

求求前輩們 指點錯誤訊息該如何解決??

(弔詭的是 同樣的程式碼、環境,小弟上午時可以執行,一個午休後就壞掉了)

以下為程式碼畫面

#from pytube import YouTube
import pytube

#ask for the link from user
link = input("Enter the link of YouTube video you want to download:  ")
yt = pytube.YouTube(link)

#Showing details
print("Title: ",yt.title)
print("Number of views: ",yt.views)
print("Length of video: ",yt.length)
print("Rating of video: ",yt.rating)
#Getting the highest resolution possible
ys = yt.streams.get_highest_resolution()

#Starting download
print("Downloading...")
ys.download()
print("Download completed!!")

錯誤訊息如下

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

問過GOOGLE大神 其中給的解決方法都是版本解決問題

以下為 pytube版本

有試過 pytube3 pytube各種版本 皆無法解決

跪求大神們求助!!~~~

看更多先前的討論...收起先前的討論...
尼克 iT邦大師 1 級 ‧ 2022-01-05 16:20:55 檢舉
你這樣方式貼程式碼,別人很難幫忙!
難神 iT邦新手 5 級 ‧ 2022-01-05 16:24:21 檢舉
不好意思 已補上 小弟第一次發文 請前輩們見諒。
推測是 line 1 , line 2 , import 的部分 衝突了.你的line 1 加了註解,但有沒有save?
是不是先把line 1 刪除,然後save,再執行看看.
難神 iT邦新手 5 級 ‧ 2022-01-05 18:22:01 檢舉
大大您好剛剛試過了,衝突問題是一樣的,謝謝您的回覆。
jiatool iT邦研究生 4 級 ‧ 2022-01-05 21:34:16 檢舉
跟 lab.py 同一層資料夾底下,有其他檔案嗎?
難神 iT邦新手 5 級 ‧ 2022-01-06 08:51:25 檢舉
感謝 jiatool 大提點!!!
找出兩個問題點:
1.Pytube不可與其他檔案放在一起
2.名稱不能為pytube.py
只要避免這兩點就可以執行了!!!
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友回答

立即登入回答