gpt4 book ai didi

python - 导入错误 : cannot import name 'quote'

转载 作者:行者123 更新时间:2023-12-03 15:54:39 31 4
gpt4 key购买 nike

我已经学习了 Python 的基础知识,所以尝试了下面的代码

from pytube import YouTube

Save_path="E:\python\youtube downloader"

link="https://www.youtube.com/watch?v=xWOoBJUqlbI"

try:
yt=YouTube(link)

except:
print("Connection error!")


mp4file=yt.filter('mp4')

yt.set_filename("ashshak")

d_file=yt.get(mp4files[-1].extention,mp4files[-1].resolution)

try:
d_file.download(Save_path)

except:
print("Error in downlaod")
print("Download failed")

当我尝试此代码或使用下面给出的 GUI 界面代码时,编译器将显示此错误。但我已经安装了“pip install pytube”库
Traceback (most recent call last):
File "E:\python\youtube downloader\practiceyoutube.py", line 1, in <module>
from pytube import YouTube
File "C:\Users\PC\AppData\Local\Programs\Python\Python36\lib\site-packages\pytube\__init__.py", line 16, in <module>
from pytube.streams import Stream
File "C:\Users\PC\AppData\Local\Programs\Python\Python36\lib\site-packages\pytube\streams.py", line 17, in <module>
from pytube import extract
File "C:\Users\PC\AppData\Local\Programs\Python\Python36\lib\site-packages\pytube\extract.py", line 7, in <module>
from pytube.compat import quote
ImportError: cannot import name 'quote'

我在这里遇到了什么问题。我已经完成了pyhton的所有基础。所以我渴望在 pyhton 中进行一些新项目。有人可以帮我吗?

这是我在这里使用的 GUI 代码,但在这里也有同样的问题。
import tkinter as tk


from pytube import YouTube
def downloadVid():
global E1
string =E1.get()
yt = YouTube(str(string))
videos = yt.get_videos()
s=1
for v in videos:
print(str(s) + '.' + str(v))
s +=1
n=int(input("Enter your choice"))
vid=videos[n-1]
destination=str(input("Enter your destination"))
vid.download(destination)
print(yt.filename+"\n Ha been downloaded")
root=tk.Tk()

w=tk.Label(root,text="Youtube Downloader")
w.pack()


E1=tk.Entry(root,bd=5)
E1.pack(side=tk.TOP)


button=tk.Button(root,text="Download",fg="red",command=downloadVid )
button.pack(side=tk.BOTTOM)

root.mainloop()

最佳答案

我发现这个github问题有一个可能的解决方案:
ImportError: cannot import name 'quote' from 'pytube.compat'

pip uninstall pytube
pip install pytube3

关于python - 导入错误 : cannot import name 'quote' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62146090/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com